Camera movement between different rooms in my level

Hi guys,

I have a level with 3 different rooms next to each other (left to right). In each room the user is controlling a ball and needs to achieve some task to access the next room.

I want the camera in every room to follow the ball left to right with some constraint (clamping on the Y axis to not see the next room when the ball move to close to the wall). When the player finish the room, the ball teleport to the second room and I want the camera to zoom out a little bit and follow the ball to the next room.

I don’t really know how to achieve that ? Should I use a spline with a camera on it that follow the ball ? Should I make multiple spline in each room and the camera jump between the spline ? Can I add constrain on a spline to limit the movement of the camera on each room ?

I’m open to any suggestion or help :slight_smile: If something is not clear on you need more details let me know I will edit the question.

Hey @Mr.Devos!

A timeline is likely the answer here!

You can add multiple variables and tracks to the timeline, and on the update execution line, have a lerp to one variable to zoom ( use a float going from 0 to 1, then 1 to 0 at the end) and another lerp for location (use a second float going from 0 to 1 in the timeline). You’ll use these floats as the Alpha for your LERP nodes. As the timeline is time-based, you can create some interesting interactions with that. :slight_smile:

If you need some more info, let us know, but give that a try and see if you can figure the rest out based on the rest of your code! :slight_smile:

Hi @Mind-Brain , thanks a lot for your answer. I never used Timeline so I will give it a try. Should I use the timeline only to move from one room to the other when the first room is finished or can I use the timeline to also control my camera on each room to follow the ball ?

How to I move the camera in each room from left to right ? Should I use a camera boom or a spline ? Or will timeline help there ?

You can set “target camera location” as a vector dynamically before switching rooms, and use that as your “B” for your camera movement (not zoom) LERP. Use your old camera location as the “A”, then after the LERP you pass that value into “SetLocation” and it will slide along! You don’t need a boom or a spline! :slight_smile:

Ok so If I understand correctly I use the timeline node to follow the ball in every room and also the timeline node to transition between two rooms using the LERP with an alpha value (for the zoom). And also use LERP node for the movement of the camera along the Y axis (left to right)

Am I correct ?

The timeline will only be used for the room-to-room transition.

For following the ball, wherever the camera is, use a “LookAt” node with the camera location as the start and the ball location as the target, and a set rotation node with the camera as the target! :slight_smile:

Hi @Mind-Brain,

Yeah I figure it out that by playing with the timeline and a camera. Thanks a lot for your help :slight_smile: I have a last question for the camera. Should it be a component of the pawn or should I make a BP_Camera that I spawn in my level ? Is there any avantage or inconvenient using one over the other ?

Since the camera is more of a level-based thing, with a side view, I absolutely recommend using a camera actor, not attaching it to the character! :slight_smile:

1 Like

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