Rotate player to the camera

I am trying to make the player rotate according to input

  • w: look away

  • a & d: look left/right

  • s: look to the camera

How do I implement this? Also, how can I rotate this smoothly?

Thx in advance

P.s.: I forgot to mention that I also want to rotate the player according to the camera

Hi @SayHiToMePls,

One way is to rework your existing movement code and instead of using the resulting direction at the end to move your player, use it to rotate him.

You can use the following entity method, lookAt, to have your player look towards the calculated point:

I read the page, but I didn’t get any smarter. How exactly do I make the player (smoothly) rotate?

To smoothly rotate you say use vector lerp. Do a quick search on the forums and you will find some results on smooth look at and lerping.

Hi again,

it’s great that you try to motivate to find the solution for myself. Unfortunately, I’m still not able to fix my problems. To be honest, I don’t know where to look exactly in the forum (A few links would be nice). But firstly, I want to get the controls right.

My problems are:

  • The more vertical I look down to the player, the slower it moves forward or backward, but sideways moves with the intended speed

  • I want the player to have more weight in its movement. So it should start off slow and then be very fast. And when letting go of the buttons, it should decelerate a bit before coming to a halt.

  • The player should rotate according to direction it is moving