Have a camera tracking the movement while looking at an entity

I am trying to have my camera follow behind an entity by 2. The entity is constantly spinning. I can’t for the life of me figure out how to do it. Does anyone have an example they could please point me to?

Add this camera as a child of the Entity to be followed. This will make the camera follow exactly all the Entity movements and rotations

1 Like

Tutorial: Third Person Camera

1 Like

Thanks. I understand what is happening with the code, but the movement seems to be forward and backwards, left and right. What i am building will have the enitity rotating so the camera needs to adjust to the actual rotation which at times will be negative. This code pops to the wrong position then.

Any thoughts?

If I get it right, you will need to create a target rotation. Every time that your character moves you set this target rotation YAW to the backward of your character. In that way you will be able to slerp the rotation gradually until your desired angle.
OBS: The OrbitCamera script already has the target, yaw and linear interpolation systems, so i suggest you to use it

Thanks, unfortunately I don’t understand what Yaw and Slerp are. Are there any good tutorials to describe that?


Yaw is rotation on the Y-axis (in playcanvas). Slerp is spherical linear interpolation. Slerp effectivly interpolates 2 quartonians more accurately than Lerp. Although this is only really noticeable when the rotations are far apart.

If in doubt use Slerp, unless your game runs slow due to it.