Prevent a top-down camera from showing outside map.

I have a top-down perspective camera following the player and a map with walls in the borders. I just want the camera to stop just so it doesn’t show what’s outside the walls of the map (basically because there is nothing).

The camera is inside the blueprint character, more or less like the top-down template character blueprint.

I have tried with several invisible blocking volumens walls and camera blocking ones, but instead of stopping at the wall, the camera just climb to the top of the invisible wall and past above it.

I am looking for a solution to this as well. Have you found anything yet?

1 Like

The easiest way would be to make thicker walls, or scenery around the outside.

If you wanted a pure code solution, then you would want to query the world for it’s extents and then stop the camera from moving beyond them.

So you would put in a branch node, and if the camera’s next update in X, for example, would take it beyond the wall, don’t allow that movement to be applied.

For the purpose of a simple prototype, you could use a big box component and inside it use the ‘get box extents’ node to calculate where the edges are. If your map is more complex, then I would consider doing it the way it’s done in AAA.

You create “camera only” collision volumes that other things can pass through, but not the camera. Now, it is possible to set up new collision categories in UE4, but luckily the camera collision category is one they’ve already got in there. So in the details tab of any mesh, set the collision presets to be camera only. Now put big blocking volumes around your map.

51747-capture.png

The good thing about this approach is that you can have accurate collision around something like a cube, for the character to interact with, but you can then place a camera only cylinder around that same cube so if it ever hits it, it will more smoothly transition around the object.

So note that for your example you will probably want the camera blocking volumes to intrude into the map so it stops short of the edges.

Lastly, if you have access to the GDC vault, there is an incredible video made by the so called “gamatographer” of Journey. The talk is called 50 camera mistakes. If you’re interested in this, it’s an amazing resource. In fact, here’s the link but you do need vault access http://www.gdcvault.com/play/1020460/50-Camera

1 Like

Well, yes and no. Adding some scenery around the outside be a solution or workaround. But it’s not always be the first choice. Sometimes it would be better to limit camera movement. I tried it with camera blocking volumes, which kinda works, but not in all circumstances…

Thanks for you detailed answer, Asher! I will gve your ideas some try after my return by the end of this week.

Hello!
What did work for you?
cheers
Hannes