Skip to main content
gamedev.net
🔒 Locked

Collision response problem

Started by NeonGE Oct 7, 2002 at 11:46 AM 0 replies 500+ views
Original Post
NeonGE
NeonGE
Hi, im writing a little collision detector with dx8, and everything is fine, but when i try to manage the collision response (sliding) my object bounce in other direction, any idea?
--------------------------------------------- If God with me, Who against me?Personal Web Samuel Prince Blog...
helix
helix
Perhaps show some code or give a little more detail? I''ve recently done something similar so I might be able to help.

Here''s the code I have for my collision resolution.

  
// Find depth of penetration

float depth = m_fRadius - Util::PointToPlaneDist( pn, &m_vPos ); // pn is a PointNormal object for the plane I''m testing (simple demo in a cube room)


// Scale normal by depth of penetration

D3DXVECTOR3 vec = pn->vNormal;
vec *= depth;

// Move along the normal and it should put us right at the edge of the wall so we can slide

m_vPos -= vec;


Then do collision test again and resolution if necessary. I found that to work really well and it''s simple. Hopefully that helps some?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.