Collision response
I finally have my collisions working but the camera movement has become horrible. When inside a structure it has become very easy to get stuck in tight spaces.
Can anyone suggest any methods to allow the camera to move along walls etc as collisions occur instead of just not allowing it to move at all when it hits something.?
you could take the normalized normal of the wall, let''s call it n. when the player (or camera) hits the wall, you can compute the part of the velocity vector v perpendicular to the wall with the dot product:
(n*v) * n
Subtract this vector from the velocity vector to get the veloctiy parallel to the wall:
vnew = v - (n*v) * n;
when you''re already on the wall you should reduce the velocity every timestep to simulate friction... and with force/acceleration vectors you do the same thing as with the velocity vector when hitting the wall.
(n*v) * n
Subtract this vector from the velocity vector to get the veloctiy parallel to the wall:
vnew = v - (n*v) * n;
when you''re already on the wall you should reduce the velocity every timestep to simulate friction... and with force/acceleration vectors you do the same thing as with the velocity vector when hitting the wall.
Visit our homepage: www.rarebyte.de.stGA
An alternative solution would be to let the object move as far as it would so rather than just projecting the move onto the wall, you move a full move along the wall instead. Do this using the cross product
vnew=(n*v)*n
This will tend to look a little odd, but it will keep the speed of your object constant... of course, with this method, it''s possible to fall into (near) infinite loops by repeatedly colliding with walls in a tight corner.
vnew=(n*v)*n
This will tend to look a little odd, but it will keep the speed of your object constant... of course, with this method, it''s possible to fall into (near) infinite loops by repeatedly colliding with walls in a tight corner.
when you build the geometry, create large simple volumes in which the camera is allowed to move. Exclude tight spaces. Low memory overhead, no faffing around with extra maths.
********
A Problem Worthy of Attack
Proves It's Worth by Fighting Back
[edited by - walkingcarcass on December 18, 2002 3:09:13 PM]
********
A Problem Worthy of Attack
Proves It's Worth by Fighting Back
[edited by - walkingcarcass on December 18, 2002 3:09:13 PM]
spraff.net: don't laugh, I'm still just starting...
I had a similar prob with my fps demo..
Basically you want to do as follows..
1. collision test move vector.
2. compute the collision point on wall
3. work out wall slide point (point on plane calc using the remaining move vector that pierced the wall)
4. move both the collision point and the wall sliding point a timy bit away from the wall using the wall normal.
5. repeat process using the new move vector till no move vector is left.
empty / solid
space / space
/
slide V // <-wall
__________//______
move V / wall pierce V
/
note:
you need to reposition your points because they are the collision points, they have already collided with the wall and such will keep colliding no matter what you do, unless you move them back awy from the wall.
becareful of acute angles and the amount of dist you reposition the points as moving into a tight corner could ping-pong you off the walls or push you outside of them depending on how you do your testing..
you should allow movement to come from outside of the walls (solid space) back into empty space to prevent some wall sticking that may occur with strange geometry.
with the wall normal you can do nice rebounding effects aswell ( i had a spray cannon tha bounced particles of the walls in my demo)
Basically you want to do as follows..
1. collision test move vector.
2. compute the collision point on wall
3. work out wall slide point (point on plane calc using the remaining move vector that pierced the wall)
4. move both the collision point and the wall sliding point a timy bit away from the wall using the wall normal.
5. repeat process using the new move vector till no move vector is left.
empty / solid
space / space
/
slide V // <-wall
__________//______
move V / wall pierce V
/
note:
you need to reposition your points because they are the collision points, they have already collided with the wall and such will keep colliding no matter what you do, unless you move them back awy from the wall.
becareful of acute angles and the amount of dist you reposition the points as moving into a tight corner could ping-pong you off the walls or push you outside of them depending on how you do your testing..
you should allow movement to come from outside of the walls (solid space) back into empty space to prevent some wall sticking that may occur with strange geometry.
with the wall normal you can do nice rebounding effects aswell ( i had a spray cannon tha bounced particles of the walls in my demo)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement