-
-
Save robertcedwards/dbaa2955a6e6e13f06df to your computer and use it in GitHub Desktop.
| 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; | |
| } | |
| } |
It's good but very slow
you can change the speed
HOWWW
Thanks it worked I just had to remove the Rigidbody so it doesn't fly all over the terrain
THANKS !!
It did, but it worked very slowly. I'll try another method. Thanks anyway! :)
making rigidbody a class in unity doesn't work for me. it gives me an error
the "vector3" in my visual studio it's not gteen, and it not works. please help!
hover on it and there will be a drop which is showing "using:UnityEngine" or something start with "using" tap on it but make sure you are using the lastest version of the unity.
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;
{
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.RightArrow)){
transform.position += Vector3.right * speed * Time.deltaTime;
}
if (Input.GetKeyDown(KeyCode.LeftArrow)){
transform.position += Vector3.left* speed * Time.deltaTime;
}
if (Input.GetKeyDown(KeyCode.UpArrow)){
transform.position += Vector3.forward * speed * Time.deltaTime;
}
if (Input.GetKeyDown(KeyCode.DownArrow)){
transform.position += Vector3.back* speed * Time.deltaTime;
}
}
}
it doesn't work,instead it does this
help.mp4