Skip to content

Instantly share code, notes, and snippets.

@robertcedwards
Last active February 25, 2024 22:27
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertcedwards/dbaa2955a6e6e13f06df to your computer and use it in GitHub Desktop.
Save robertcedwards/dbaa2955a6e6e13f06df to your computer and use it in GitHub Desktop.
Movement Script in C# for Unity
private float speed = 2.0f;
public GameObject character;
void Update () {
if (Input.GetKey(KeyCode.RightArrow)){
transform.position += Vector3.right * speed * Time.deltaTime;
}
if (Input.GetKey(KeyCode.LeftArrow)){
transform.position += Vector3.left* speed * Time.deltaTime;
}
if (Input.GetKey(KeyCode.UpArrow)){
transform.position += Vector3.forward * speed * Time.deltaTime;
}
if (Input.GetKey(KeyCode.DownArrow)){
transform.position += Vector3.back* speed * Time.deltaTime;
}
}
@XeroPlayer
Copy link

making rigidbody a class in unity doesn't work for me. it gives me an error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment