Download

Tracking

Hey UE family, Got a tough one for y’all. So I am trying to make the player’s camera follow an object when its moving (you know like when you are watching the ball in tennis back and and forth). Now here’s the hard part, I also want to control the object and move it back and forth with arrow keys.

P.S this is in third person.

Wow, this is really interesting. I wonder how this would work.

Like this perhaps:

A Pawn with an absolute camera:

Hmmm I did forget one important piece of info. It also needs to move on a spline. I have it so it moves on the spline by using arrows/d-pad and I have the player looking at the object while its moving (see attachments) however when I try to set the location via a line trace from the camera it spazes out.

Also the setup I posted is the working one where I use the D-Pad which moves the object along the spline

The reason it spazzes out is because you’ve made a cyclic dependency: the rotation of the camera depends on the position of the object, but the position of the object depends on the rotation of the camera (camera<->object), which causes an infinite loop (camera->object->camera->object->camera->object->…).

You need to make it so that the dependency only goes in one order (camera->object or object->camera). For example, instead of doing a line trace from the camera, do it from the mouse whenever you click; this would give an effect similar to the camera movement in a top-down game, where your click moves the character and the character moves the camera (click->character->camera). Since the sequence terminates and has no cyclic dependency, it doesn’t cause an infinite loop.