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:
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?
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.
You need the ending value in the timeline to be 1.
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)