How can I have a camera with an Orbit Controls component smoothly follow a moving target?

Hey guys,
In my project, I have a moving target, and I want my camera to look at the moving target, and smoothly follow it while staying within a certain radius limit of the target as set by the OrbitControls.

  • I have a moving cube

  • I have a camera with a LookAtConstraint so it looks at the moving cube.

  • The camera also has an OrbitControls component attached with some limits set for the min and max zoom

  • I cant seem to get that set up to work. I want the camera to essentially function as if it was childed to the moving object, however childing it obviously created really bad stutter on mobile devices.
    I have also tried having a target object follow the moving cube via a Smooth Follow component, and then having the camera constraint reference that target object, but I still cant seem to get the camera to stay within a certain radius of the moving target.

I have referenced the third person character controller sample, but cannot get it to work.

I have included a link here to show the current state of the camera in my horse racing game. You can see the excessive camera jitter as I have it childed to the object its looking at, which I want to change. However the actual camera functionality in the clip is exactly what I want.

This link here shows the current state of my attempts trying to recreate the functionality above, by referencing the third person character sample but you can see how it doesnt maintain distance, it just watches the cube as it moves away unlike the other link with the horses above.

Hi, have you tried using the SmoothFollow component?

Hey Marcel. Yes I have, and I still cant get it even remotely close to what Im looking for. In this video here, the camera has a smooth follow with the target set as the moving cube, and the look at constraint set to the cube also. You can see how this is more of a “fly by” result.

You can just add a SmoothFollow to your camera and assign the object it should follow. That’s all you need

Video Unity

Video Browser

If you want OrbitControls you need to parent your camera to the object that is being moved around

Thanks Marcel. I was getting mixed up by having the follow and the orbit both directly on the camera.

This topic was automatically closed 13 days after the last reply. New replies are no longer allowed.