• Advertisement
Sign in to follow this  

Keeping camera inside map bounds

This topic is 1276 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement