- Home /
c# how to get to idle from walk
i have a basic move script and key press on the w witcn is move forward i want it to play the walk animation witch i got working but when the player stops i want it to return to the idle animation this is the line of code i am using for movement
private void MovePlayer(){
/***** CAN BE MODIFIED *****/
//
if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow)) {
transform.Translate(new Vector3(0,0,1) * speed);
animation.Play("Walk");
} else if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow)) {
transform.Translate(new Vector3(0,0,-1) * speed);
}
if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow)) {
transform.Rotate(new Vector3(0,-1,0) * 2);
} else if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow)) {
transform.Rotate(new Vector3(0,1,0) * 2);
}
Comment
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
how can i auto target Gameobject on startup 1 Answer
c# help fix argument is out of range error 1 Answer
Question about attaching game objects to certain bones 1 Answer
Destroy Gameobject once 0 health 2 Answers