Created
October 16, 2017 23:24
-
-
Save igolden/59af4c47fc0de9113f263bda36600d87 to your computer and use it in GitHub Desktop.
Simple character movement in Unity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class BoxController : MonoBehaviour { | |
public float speed = 10.0F; | |
public float rotationSpeed = 100.0F; | |
void Update() | |
{ | |
float translation = Input.GetAxis("Vertical") * speed; | |
float rotation = Input.GetAxis("Horizontal") * rotationSpeed; | |
translation *= Time.deltaTime; | |
rotation *= Time.deltaTime; | |
transform.Translate(0, 0, translation); | |
transform.Rotate(0, rotation, 0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment