Character actor with lock on camera moves away from target while strafing

Hey there! I have made some code recently for a lock on camera system… As you can see, it’s just a Set Control Rotation based on a Look At from the Camera to the Locked target.

Issue is, I have found out that while strafing, while locked on, the player will move away from the target. This backwards movement grows stronger with proximity to the target.

I have tried a few methods based on applying a forward movement input while strafing locked onto a target, but it doesn’t yield results…

How can I make the player strafe in circles around a target while locked on?

You’d need to Add Movement Input in a direction that is perpendicular - consider this snippet based on the 3rd person template:

  • using A/D to strafe
  • Control Rotation derives from Look At Rotation
  • Orient to Movement is disabled
  • the pawn is using Controller Rotation Yaw
1 Like

This seems like it works at first glance, but upon recreating the code and testing I am met with this:

Green is the player movement speed, blue is the horizontal distance from the target.

As you can see, as the player strafes they move further and further away.

I believe this is because the player movement and orientation rotation are applied one after another and not at the same time, which creates a small offset that builds up over time.

I feel the best solution to avoid this is to rotate the vector a tiny bit to simulate rotating the object with a pivot on the target… Thing is, I don’t know the math for that.