Archived

This topic is now archived and is closed to further replies.

Collision : Smooth surface sliding (Quake series)

This topic is 6388 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I''ve finaly added collision detection to my game, but one thing makes me mad about it. You get caught on the walls. How do games like Quake and UT make you slide across the walls without catching? Did I just speak in a riddle? heehehe Please tell me if you don''t understand and I''ll try to simplify a bit better. I''m not good at describing what I want Justin Eslinger

Share this post


Link to post
Share on other sites
I found out how to do this on accident. All you have to do is multiply the triangle normal by the min. distance from the plane. After the collision occurs.

(I finally figured out how to say it )

------------------------
Captured Reality.

Share this post


Link to post
Share on other sites
what''s the min. distance from the plane? what is that?
what do you to the velocity or direction vector after the collision occurs,( to slide against the wall )?

quote:
Original post by nes8bit

I found out how to do this on accident. All you have to do is multiply the triangle normal by the min. distance from the plane. After the collision occurs.

(I finally figured out how to say it )

------------------------
Captured Reality.


Share this post


Link to post
Share on other sites
on flipcode there''s a doc in the Development Tutorials sections called collision detection using bounding ellipoids (or something similar). read it, as it describes in great detail how to "slide" along a surface. allthough it''s for bounding elipsoids (3D ovals), the techniques still apply. go read

CJ

Share this post


Link to post
Share on other sites
To make you slide along the wall all you do is zero the velocity perpendicular to the wall and leave the velocity parallel to the wall as it is. The min. distance from the plane is the minimum distance from the wall, i.e. the closest you can get to the wall.

Share this post


Link to post
Share on other sites
quote:
Original post by youngo

what''s the min. distance from the plane? what is that?
what do you to the velocity or direction vector after the collision occurs,( to slide against the wall )?



you do exactally what I say to change the velocity/direction. Actually you don''t change the velocity or direction. All you do is change the position to create the illusion of sliding. Also the "min. distance" is basically how far the player must be at all times from the wall. Without this, you will collide exactally at the plane''s point.

------------------------
Captured Reality.

Share this post


Link to post
Share on other sites
nes is right. Basically what you are doing is finding the amount that you would have moved parallel to the wall had you kept walking, and taking away any motion normal to the wall. Kind of like breaking down a vector into its x, y values and just moving it in the x direction. Hopefully this clears it up a little.

-BacksideSnap-

Share this post


Link to post
Share on other sites
I'm pretty glad that I don't sound crazy. It's also very hard to explain without drawing a picture. I'm way too lazy to draw one right now. If you want me to give you an example, just ask. It's gonna require YOU to write some code though. (I do pseudo code )

I don't know why, but I have a feeling you're in San Diego -BacksideSnap-

------------------------
Captured Reality.

Edited by - nes8bit on June 15, 2000 5:01:16 PM

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
There''s a couple of ways of handling ''sliding'', but here''s the way I do it:

I assume that you have acceleration values for your player, i.e. I call them ax, ay, az. To see if you can move along a wall, just check each component individually.

So, you might have something like this:

x = player_x_coordinate;
y = player_y_coordinate;
z = player_z_coordinate;

ax = requested_acceleration; (or whatever, you get it)
ay = ...
az = ...

// Check each thing separately...
if (Collision(x + ax, y, z))
ax = 0;
if (Collision(x, y + ay, z))
ay = 0;
if (Collision(x, y, z + az))
az = 0;

x += ax;
y += ay;
z += az;


Ok? That''s the way I''ve been doing it in the last 5 years or so. See an example with "Tank Arena 3D" at
www.smidge-tech.co.uk/prog-windows.html

======
Smidge
======

Share this post


Link to post
Share on other sites
quote:
Original post by -BacksideSnap-

I think nes is right once again. Don''t check for collision three times, it will slow you way down. Check for it once and move accordingly.

nes: Your close. My heart is in San Diego, but I live in Los Angeles, which isn''t bad.

-BacksideSnap-

Yo damn straight



------------------------
Captured Reality.

Share this post


Link to post
Share on other sites
Hmmm, perhaps I wasn''t too clear on this..

Ok! I draw the world as I would a 2d tiling game.

Now, each block has a centerx value and a centerz value, plus they have a type value and a visible value.

Now, every time I check the input I check this :

for( int loop = 0; loop<1023; loop++)
{
if( block[loop].visible)
if( block[loop].type == 2) // 2 = wall
// check for collision
}

The code I had in the //check for collision // always worked but you got caught on the blocks.

Now I''m asking, how do I check if I collided w/ the x axis or the z axis so that I can stop it from moving and still move the other? (Btw, the blocks are 24x24... so the centerx or z will be 12, 24, 36, and so on. So add 12 or minus 12 to get it to collide right.)


Justin Eslinger

Share this post


Link to post
Share on other sites
Oh well, %#&^!

3D collision detection is completely different from 2D collision detection although you CAN use the same style in 2D as in 3D. I''m sorry, but I don''t know how to do it in 2d.

------------------------
Captured Reality.

Share this post


Link to post
Share on other sites