The issue where the character rotates 360 degrees when changing direction

Hello everyone, I’ve been working on my project with a lot of help from here.

Currently, the issue I’m facing is that when the character changes direction, it rotates 360 degrees.

Third Person Example | Babylon.js Playground (babylonjs.com)

Let me explain it by showing you a video.

Video 1:

If you watch the video, you’ll see that the character rotates 360 degrees to find the right direction. The way I want it to behave is as follows.

I want it to move slightly in the direction it’s facing, just like in the video.

If you look at the current implemented code, it adds the direction value to the y-value of the target, takes the remainder when divided by 360, and applies the result.

No matter how much I think, I can’t come up with any other method.
Please Help me :face_holding_back_tears:

I hope you found this example helpful

2 Likes

That’s what I’m looking for.
THANK YOU SO MUCH ! @late-autumn-give-ear