Last active
June 1, 2025 10:44
-
-
Save robertcedwards/dbaa2955a6e6e13f06df to your computer and use it in GitHub Desktop.
Movement Script in C# for Unity
This file contains hidden or 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
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; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
not working using UnityEngine;
public class Move_ : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
private float speed = 2.0f;
public GameObject character;
{
}