Handling collisions on my own.Problems at collisionbox edges

KayJ
Posts: 4
Joined: Mon Oct 12, 2009 2:11 pm

Handling collisions on my own.Problems at collisionbox edges

Post by KayJ »

Hi,

I've got a static world consisting of collision boxes and a moving camera that is surrounded by a collision sphere. When the camera collides with e.g. a wall in the world a callback notifies me of this collision.

Then I try manually to compute the position the camera should move to. I use the bullet physics only for detecting this collisions.

I compute the new position of the camera sphere with the following code. m_kCollisionPoint is a btManifoldPoint object. rkDesiredPosition is the position that would have been set if no collision would have been detected.

Vector kGlobalNormalOnSphere = m_kCollisionPoint.m_normalWorldOnB;
float fIndentationDepth = m_kCollisionPoint.m_distance1;

Vector kNewPosition(
rkDesiredPosition +
-kGlobalNormalOnSphere * abs( fIndentationDepth));

This works fine in most cases. At the contact edge of two collision boxes problems occure. The camera is like flickering (moving some degree to the left, right, left, right... ). There is obviously a collision detected between the collision sphere and collision box 1 and also a collision between collision sphere and collision box 2. My computation is pushing the camera from one position to another back to the first one and so on...

Does someone have an idea how to modify my computation to solve this problem?

Thanks in advance!

KayJ
You do not have the required permissions to view the files attached to this post.
Mattg
Posts: 12
Joined: Thu Oct 22, 2009 12:50 am

Re: Handling collisions on my own.Problems at collisionbox edges

Post by Mattg »

Maybe you could try use the character controller and let it solve the collision for you, it probably a fairly good match to what you try to do.

Another approach could be to use convexSweepTest and move the sphere to where it start collide instead of first moving and then compensate which it sounds like you're doing.