0

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.

enter image description here

1 Answer 1

1

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 
}

https://docs.unity3d.com/ScriptReference/Vector3.Lerp.html

Sign up to request clarification or add additional context in comments.

1 Comment

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.