Zoom in and out depending on how close 2 actors are from each other

Hi everyone !

I just started working on a smash-like platform fighting game and I have a bit of a problem with how the camera works. I worked on Unity before and just recently made the switch to Unreal as I knew next to nothing about it.

In Smash, the camera seems to focus on the center point between two characters and zoom in if they’re close to each other or out they get farther away.

I managed to implement this system (to an extent) :

(I’m currently using 1 player and a placeholder skeletal mesh as a second one)


When I print the CurrentDistAlpha, I see that it’s zooming in and out as long as it stays in the 0-1 range of the clamp (for reference, T-posing mesh is at about 0.8)

On this side it works

However as soon as I cross the T posing mesh and go out of the 0-1 range, it obviously doesn’t zoom out.

No zoom out

So my question is : how should I do to make it zoom out again once the characters have passed each other ?
My guess is with a distance comparison using the “Vector (Distance)” or “Get Distance To” nodes but I have no idea how to use their values to influence the CurrDistAlpha of my Lerp.
Could anyone help me ? :sweat_smile:

The issue is you’re not using a distance metric per say for the “NormalizeToRange” call. Given that your midpoint is really just the focal point of the camera I would instead use the actual distance between the two actors. So essentially where you’re calculating the midpoint, also calculate the distance. This will give you a value that doesn’t care about direction. Plug that into NormalizeToRange. You might need to adjust your near and far dist to accommodate this change.

1 Like

It works ! I can’t believe it was that simple :laughing: Thank you !