Skip to content

Instantly share code, notes, and snippets.

@igolden
Created October 16, 2017 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igolden/59af4c47fc0de9113f263bda36600d87 to your computer and use it in GitHub Desktop.
Save igolden/59af4c47fc0de9113f263bda36600d87 to your computer and use it in GitHub Desktop.
Simple character movement in Unity
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