Answer the question
In order to leave comments, you need to log in
What script is needed to move the character from the keyboard?
Tell me a script or lesson for character movement from the keyboard. So that the control is like: W - forward, S - back, A and D - turn the character on the spot. Classically CharacterController does not provide this.
Answer the question
In order to leave comments, you need to log in
Try it.
public GameObject obj;
public float range = 5f, moveSpeed = 3f, turnSpeed = 40f; //значения можно менять
void Update ()
{
if(Input.GetKey(KeyCode.UpArrow))
obj.transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime); // движения вверх.
if(Input.GetKey(KeyCode.DownArrow))
obj.transform.Translate(-Vector3.forward * moveSpeed * Time.deltaTime); //движения в низ
if(Input.GetKey(KeyCode.LeftArrow))
obj.transform.Rotate(Vector3.up, -turnSpeed * Time.deltaTime); // поворот в право
if(Input.GetKey(KeyCode.RightArrow))
obj.transform.Rotate(Vector3.up, turnSpeed * Time.deltaTime); //поворот влево
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question