Camera follows terrain

Hi, I’m making an archviz cinematic. I can easily walk the camera around an interior at a constant (eye) height from the ground – all the planes are horizontal. But I now want to take the camera outside and have it follow a path up a hillside. How do I keep the camera the same height above the changing height of the terrain? Thanks!

Hi, you can use a spline as path and a timeline to move the camera along the spline (there’s a node called “Get Location at Distance Along Spline”). When you set the position of the camera along the spline only use the x and y position from the spline. Then do a linetrace in z-direction to get the position of the landscape. The z part of the hit location will be the height of the landscape. You can then add your desired camera height above the ground to it and use the result as your z value.

chrudimer, Thanks for your response. Unfortunately, I’m pretty ignorant and only vaguely understand what you’re telling me (this looks like Blueprint work, which I’ve never done before) – but you’ve given me a place to start my learning curve.

I have never used sequencer so there may be a way to achieve what you want without blueprints (you could look at “camera rig rail”).

As for with the blueprints, you would first need to create a path for the camera to follow (that’s the spline). So I would create a blueprint for that (Right click in the content browser → Blueprint Class → Actor). Then inside the actor Add Component → Spline. Then drag and drop the blueprint in the level. When selecting a point of the spline and holding “ALT” and using left mouse button to move it you can create new spline points That spline you see in the editor will be the path the camera will follow (except for the height).

Then you would create a new blueprint where you would put your camera in. Then you would want something to actually move the camera along the spline. Therefore you would add a timeline in the event graph (you can add it after the event begin play, so the camera will start moving when the game starts) and add a float track to it (with two keys, one at 0, 0 one at value 1 with time x, x would be the time the camera needs to complete the path and you would need to change the length of the timeline as well).

Spline Actor is the name of the spline actor blueprint you’ve created previously (if you would name it differently then you would set a different parameter in “Get All Actors Of Class”).

« I have never used sequencer so there may be a way to achieve what you want without blueprints (you could look at “camera rig rail”). »

You’re right, it can be done in sequencer. What I’m doing at the moment is manually navigating the camera through the scene and having sequencer drop keyframes (like breadcrumbs) along the path as I go. The problem with this – as it’s all done by eyeballing – is it involves quite a bit of trial-and-error and fiddling with keyframes. Hence my question. I was hoping to be able to enter a “height above terrain” number somewhere and the camera would automatically be maintained at that height as I pushed it along. (I dimly remember having been able to do this in some other 3D program in the past. I’m really surprised this facility seems not to exist in UE4.) I’ve found camera rig rail too much of a hassle to control once the topography becomes more complex than flat ground and simple"roller coaster" elevations.

Having said that … I’m really grateful to you for having taken the time to provide such a detailed explanation of how to go about making the blueprint. I’ll certainly set aside the time to work through it. I’ve been putting off getting to grips with blueprints for too long. Thanks again!