Sign in to follow this  
Meshboy

Sliding reflection

Recommended Posts

I am using this for subtracting the speed and get reflection vector so i can slide on the wall in my FPS. This works 100% perfect against the normalized normal of the plane(wall). sphere_velocity -= n * (sphere_velocity.dotProduct(n)); My problem here is that when i loop this on all my planes it gives me jerky sliding in edges and corners. Shouldent the normal in this case be the point from ClosestPoint on plane to camera pos? but this don´t work, then i can go through walls. i think my problem is that i don´t use correct timing procedure and calc each frame. One thing i can think of is that i don´t put the camera on the closestPoint right after collision occurs. What would your advise be to check first for solving this problem?

Share this post


Link to post
Share on other sites
Solved it! Now my Slide vector is all 3D and the same as in Quake 3 for Clipping Velocity! =) Hurray.

Moment or glory...

void PM_ClipVelocity( D3DXVECTOR3 in, D3DXVECTOR3 normal, float overbounce ) {

float backoff;
float change;
int i;

backoff = D3DXVec3Dot(&in,&normal);

if ( backoff < 0 ) {
backoff *= overbounce;
} else {
backoff /= overbounce;
}

for ( i=0 ; i<3 ; i++ ) {
change = normal[i] * backoff;
velocity[i] = in[i] - change;
}
}

But i still have problems with the camera shaking when hitting edges, and if a corner is narrow enought, i slide right through it. Must calc each frame with times or something i think...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this