Jump to content
  • Advertisement
Sign in to follow this  
Waaayoff

Collision detection - Walls??

This topic is 2872 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've been reading about collision techniques and i think i understand how to use SAT with AABBs which is exactly what i need.. But i was wondering, do i use it with walls too?

I mean.. Let's say i want a player to navigate a maze, do i use a different AABB for every single straight wall segment? How do people usually handle collisions with walls?

Also, What is a good technique to use when the collision detection brought by Bounding Boxes/Spheres is too inaccurate? For example a collision with a tree..


Thanks :)

Share this post


Link to post
Share on other sites
Advertisement
A lot depends on the way your walls are organized.

E.g.: if the walls are alligned to the axis, why use AABBs?
or: if the walls make up a tunnel or road (like in the old Descent games or as in racing games) that is defined by a line through the center of the tunnel or by the edges of the road why not calculate the distance from the line (or edges)to vehicle instead of calculation collisions against wall fragments?

Share this post


Link to post
Share on other sites
I was in.your same situation and have found success through tile maps.
I open up Photoshop with 32x32 grid lines. I make my level as confined to the grid as possible.
I then open it up with an editor I made, and it exports it to a text file.
The game then imports this text file into an array, format is as follows:
numOfRows numOfCols Pixels
00000
00100
00000

this would make a 5x3 tile map with a solid tile in the middle.
To check for collisions, you simply get all the tiles you are currently standing in and check if surrounding tiles are solid.
If the tile to the right is solid, it's left x coord is your right bound.
I give my player class a bound in 4 directions, and it is constantly updating based on the tile he is on.
It then checks on the playermove function if the move will be within his bounds.
This works quite well with 360 degree motion, only draw back is your art needs to be pretty much on the grid.

Hope I helped

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!