- Home /
Character controller with key click to move forward
I want to create 3D character controller where when the 'W' key is pressed once, the player begins to walk continuously until 'S' key is pressed to stop the player. When walking, if 'W' key is pressed again, the player starts to run, until 'S' key is pressed to slow down to walk and then pressed again to stop.
I also want to turn the player with 'A' and 'D' keys while walking or running forward.
Here is an example of what I'm looking for from another game: [https://youtu.be/_rEKBw9LcVs?t=261][1]
I'm new at coding so I'd appreciate all the help!
Answer by Deuce2008 · 4 days ago
You would do something along the lines of:
if(Input.GetKeyDown(KeyCode.W))
{
//Checks if not moving up and enables it
if (!Moving_Up)
{
Moving_Up = true;
Moving_Down = false;
}
//Checks if already moving up and if you are it sprints
if (Moving_Up)
{
Sprinting = true;
}
}
Then you would do a simple if statement to check if sprinting, moving up, etc and move your character accordingly. Hope this helps. (:
Your answer
![](https://koobas.hobune.stream/wayback/20220613061442im_/https://answers.unity.com/themes/thub/images/avi.jpg)