Keeping camera inside map bounds

Started by
2 comments, last by Zipster 9 years, 9 months ago

I have a 3d game where players can explore small maps.

Each map is bounded by walls, except for some exits.

Right now if players come close to an exit, they can look outside the map and see a skybox, this is bad.

I want the camera to be able to roam free, except in places where it would let players see outside.

There are some contraints, for example the camera always points down, so it is not possible to see the sky.

What kind of approach should I take?

Advertisement

I have a 3d game where players can explore small maps.

Each map is bounded by walls, except for some exits.

Right now if players come close to an exit, they can look outside the map and see a skybox, this is bad.

I want the camera to be able to roam free, except in places where it would let players see outside.

There are some contraints, for example the camera always points down, so it is not possible to see the sky.

What kind of approach should I take?

Create a bounding box smaller than the level, and constrain the camera to never move outside of that?


Create a bounding box smaller than the level, and constrain the camera to never move outside of that?

The camera is defined by two things, position and view direction.

Constraining the position to a box is trivial, sure, but the problem is constraining the view direction so the limits of the map are never visible.

My camera view direction vector can have any value except having the Y component pointing up (to the sky).

So I'm interested in knowing what kind of math could be used in this case.

The typical solution is to just pad the skirt of the map -- past the farthest distance the player would ever be able to see -- with additional artwork to cover up the skybox/background/etc. This ensures that the camera never interferes with gameplay while also hiding the rough edges.

This topic is closed to new replies.

Advertisement