Is there an easier way to do this?

I need the camera to reach a specific object, which in this case is represented by “vector”.
with the camera being represented by “view”. This is the blueprint:


and this is the timeline:
image

For some reason, it goes inside the object, and, once again, never stops. I don’t want it to be too fast or too slow. i want it to stop infront of the object, is there any way to animate this?

There are two things causing your issue:

  1. You need to cache your locations. Meaning on PanCamera(), set two vector variables- one equal to View->GetWorldLocation() and the other set to the passed Vector parameter. You then lerp between these. This is absolutely essential. As of now it appears on the surface to work, but as you’ve found out- it doesn’t.
    Think about how this would work with a constant lerp value- ignoring the timeline (we’ll use a constant value of 0.1). The first frame, the camera would move a tenth of the way to the target. This is good and where we hope it stops. But what happens next is it lerps another tenth of the way there… that’s bad. We continue lerping a tenth of the way there since our starting location is getting changed every single frame as we move closer. This happens for the rest of eternity- we will never actually reach the target.

  2. You need the ending value in the timeline to be 1.

1 Like

Thank you for the quick response! I appreciate it <3

1 Like

almost forgot, when the ending value in the timeline is set to 1, the camera goes inside the mesh. any way to prevent this?

The camera is only going where you’re telling it to go. As of now, that’s probably just the mesh location.
When calling pan camera, I recommend getting the forward vector of the mesh, multiplying it by some constant (ie 200- play with it), and adding it to the location you already had.

You can use a combination of GetForwardVector, GetRightVector, and GetUpVector to get the location you want.
You can get the opposite of these by simply multiplying by -1 (ForwardVector * -1 = BackwardsVector, RightVector * -1 = LeftVector, etc)

1 Like

Thank you.

1 Like

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