I am creating a game using Unity where the player has to use the wasd to move the player 1 tile at a time (3D), I would like to make the player rotate smoothly with movement accordingly when one of the keys is pressed as seen in the image below. I have tried countless approaches but still can't seem to make it work would appreciate it if you can help me out.
1 Answer
Lerping is good for moving smoothly from one position to another you can refactor code from here and call
void update() {
if (Input.GetKey("w")) {
//begin lerp up
}
//program same for asd
}
1 Comment
Jay
This is a good answer, just thought it might be helpful to add that unity stores rotation as a quaternion (even in 2D games) and there is a dedicated
Lerp function for lerping quaternions Quaternion.Slerp which might work better than Lerp