How to control a cube with the arrow keys
Tutorial, Unity
0
The most basic tutorial of all tutorials: How to move a cube with the arrow keys.
If you are new to Unity, this is a good place to start.
❤️ Subscribe to Oxmond Tutorials:
https://bit.ly/SubscribeOxmondTutorials
😷👕 Need a face mask / developer T-shirt? Drop by our shop and get a 20% DISCOUNT on your first purchase by using the discount code OXMONDSALE. Click here:
https://shop.oxmond.com/discount/OXMONDSALE
Cube script:
/* .-------. .--. .-------. .--. .--. .--. | |--.--.--------.-----.-----.--| | |_ _|--.--| |_.-----.----|__|---.-| |-----. | - |_ _| | _ | | _ | | | | | | _| _ | _| | _ | |__ --| |_______|__.__|__|__|__|_____|__|__|_____| |___| |_____|____|_____|__| |__|___._|__|_____| © OXMOND / www.oxmond.com */ using System.Collections; using System.Collections.Generic; using UnityEngine; public class Cube : MonoBehaviour { void Update () { transform.Translate(Input.GetAxis("Horizontal") * Time.deltaTime * 15f,0f,0f); transform.Translate(0f,0f, Input.GetAxis("Vertical") * Time.deltaTime * 15f); } }