Followers 0

# Collision - BoundingSphere vs BoundingBoxes Corners

## 2 posts in this topic

Hi everyone,

I'm working in XNA (C#), & after successfully making my character slide along walls (character represented as a BoundingSphere & wall as a BoundingBox) I've been strugling to solve the well known corner problem.

I've been decomposing the BoundingBox of the wall (AABB) into Planes in order to check which one was hit, descard the further ones, try to work with normals & push the player somehow away from the corner direction (in case it hits the outer part of a corner).
The problem is that there are plenty of different possible situations...

I manage my walls as BoundingBoxes, & each wall is one of them. So in a corner there are 2 BoundingBoxes which come very close one to the other. So there are many planes (outer & inner) that may be hit, from both BoundingBoxes. It's actually very difficult to manage many planes of many BoundingBoxes & get an algorith (which works for inner corners: you are indoors, & outer corners: you out outdoors).

I'll try to show my issue in a pic (seen from above), & I'd like you to help me in thinking about a solution. Is it a mistake to decompose the BB into Planes & work with them individually? (maybe I'm complicating things too much...) May I cast rays...? May I treat the corners with a fixed resolution?
I hope you can guide me somehow, I've really spent a lot of time thinking about solutions & they always match a new case in which they won't work.

Thank you so much,
Synth

P.S.: Oh, I also have an annoying problem in which when I slide along a wall I can see the interior of the "room" (I see across the wall) & I'd like to get rid of this in an elegant way...! Edited by Synthesizer
0

##### Share on other sites
For a simple scheme, this is how i would do it:

Lets say x is the position of the player and r the radius.

If x is completely inside a box, move it in direction of the normal of the nearest plane until the distance to the plane is r. This should not happen usually.

Else find the nearest point p on each box and move x in direction p - x if norm(p-x) < r.

edit: see e.g. http://www.wildbunny.co.uk/blog/2011/04/20/collision-detection-for-dummies/ for more details on the subject. Edited by Inferiarum
0

##### Share on other sites
Thank you,
I think the case of the sphere completely inside the box is almost impossible (the wall should be very thick & the player should move very quickly), but I'll analize the other case together with the info you linked. It seems pretty much interesting.

Thanks again,
Synth
0

## Create an account

Register a new account