Skip to content

Instantly share code, notes, and snippets.

@nrfm
Created September 30, 2017 07:23
Show Gist options
  • Save nrfm/35e69346eb08ccb20cc1355b845199a6 to your computer and use it in GitHub Desktop.
Save nrfm/35e69346eb08ccb20cc1355b845199a6 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class TransformFunctions : MonoBehaviour
{
public float moveSpeed = 10f;
public float turnSpeed = 50f;
void Update ()
{
if(Input.GetKey(KeyCode.UpArrow))
transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime);
if(Input.GetKey(KeyCode.DownArrow))
transform.Translate(-Vector3.forward * moveSpeed * Time.deltaTime);
if(Input.GetKey(KeyCode.LeftArrow))
transform.Rotate(Vector3.up, -turnSpeed * Time.deltaTime);
if(Input.GetKey(KeyCode.RightArrow))
transform.Rotate(Vector3.up, turnSpeed * Time.deltaTime);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment