Making a top down camera zoom in and out smoothly

I have a project using the top down preset. I want to introduce functionality where scrolling the mousewheel results in the camera zooming in and out smoothly. If I just change the camera’s location, then it isn’t smoothed and instead just snaps every time I scroll. I tried using the Camera Boom (Spring Arm Component) that’s already integrated with the TopDownCharacter.

If I move the Camera Boom up and down, then the movement is smoothed (exactly what I want). Another problem arises though: If I move my character while the camera’s relative position is not (0,0,0), the camera moves undesirably: The camera position is only correct when my character is facing upwards. If it faces any other direction, then the camera is pushed to the opposite direction. Example video

Now I somehow get why this happens. The character is the root, thus rotating it will result in the camera movement being rotated. What I don’t get though is why this doesn’t already happen with the spring arm like why that doesn’t rotate with the character and how I do apply the same property to my camera.

This is my Event setup. I already tried using “Set World Location” instead of “Set Relative Location”, but it didn’t change the behaviour.

The idea is to give interpolation a chance to smoothly arrive at the desired value:

  • here all I’m doing is changing the length of the springarm:

Do note InputAxis above fires every frame. Were you to do it with triggers, you’d need to get Tick involved as we want updates often.

The Enhanced Input’s Ongoing may be producing something similar - not sure.

1 Like

I actually had to wait multiple days for this post to go live (new account) and have already figured it out. The Spring Arm (Camera Boom) has a property called “Target Offset”, which moves the camera and also applies the spring smoothing (as long as “Camera Lag” is enabled). So it boiled down to simply adjusting that value.

2 Likes

Been searching everywhere trying to figure out how to get smoothed zooming using the camera boom and not using tick. This accomplished that. Thank you so much! :tada:

1 Like

@Potheker How are you determining the value of ‘Camera Angle’ in your example? Also trying to set up a smooth camera zoom without using ticks :frowning:

I just messed with it. What worked for me was -45 but adjust as you seem fit. start with like -15 and keep slowly going lower.