0
What code should I use to walk FPS with WASD in Unity
2 Respuestas
+ 1
+ 1
Hey Emre,
There's a few ways to go about doing this. I think the easiest would be to add a FirstPersonController component to the player (If I remember correctly, I believe you can import it from Unity's asset store). This has its own way of managing movement and should by itself use wasd by default to move the character.
To make your own, I recommend checking out the Input class.
https://docs.unity3d.com/ScriptReference/Input.html
with the default method "Update", you can frequently check for any keys that are pressed on the keyboard, then do something when they are pressed (such as move a character on w,a,s or d).
There are a few ways you can go about moving the character.
Most likely, you would want something along the lines of:
https://docs.unity3d.com/ScriptReference/Transform-position.html
For that, I'd also recommend checking out my personal favorite method: lerp
https://docs.unity3d.com/ScriptReference/Vector3.Lerp.html
Helps make it look smooth.
*Lerp may look complicated at first though*