Skip to content

Instantly share code, notes, and snippets.

@musaprg
Created December 6, 2014 16:59
Show Gist options
  • Save musaprg/eac336f0cdfeb20b2d43 to your computer and use it in GitHub Desktop.
Save musaprg/eac336f0cdfeb20b2d43 to your computer and use it in GitHub Desktop.
Moving Rotating Cube(Unity)
using UnityEngine;
using System.Collections;
public class myscript : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
this.transform.Rotate(0,1,0);
Vector3 v = this.transform.position;
if(Input.GetKey(KeyCode.A)){
v.x -= 0.05f;
}
if(Input.GetKey(KeyCode.D)){
v.x += 0.05f;
}
if(Input.GetKey(KeyCode.W)){
v.z += 0.05f;
}
if(Input.GetKey(KeyCode.S)){
v.z -= 0.05f;
}
this.transform.position = v;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment