Jump to content
  • Advertisement

Archived

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

Zealot

Collision Response

This topic is 5737 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

Ok I have two questions: I know that Quake III uses the brushes lump in BSP files for collision detection. My question is: how? Do they just read the vertex data and then whatever or is there special stuff about the way BSP files store brush data? I found a library; ColDet, and it does a smashing job on collision detection. However, it is obvious that detection is only half of the game. I was wondering if there was a standard way for first person games to do collision response. Therefore, I had this idea: You cast a ray from the object''s bounding ellipsoid or box, in all six directions (up, down, front, back, left, and right) in the direction the object is moving, then find a point of collision with the world. Now move up to that point, knowing that it is safe. If the object encounters floor changes through the bottom ray, then you can move up or down accordingly. Additionally, this could be done for any walls encounterd. I thought this up trying to find a way to do wall collision response (you know, how you can''t just say speed=0 if collision, you have to tell it what to do instead). If my idea is total crap, then can someone tell me a better way to do FPS game collision response? Thanks. En taro Adun! Doom to all who threaten the homeworld! *Protoss Zealot - Starcraft*

Share this post


Link to post
Share on other sites
Advertisement
Well your idea works ok if none of your walls are slanted, but I think the meathod I''ve been using might work a little better. I''ve also had a hard time doing collision responce, collision detection was pretty easy compared to this. I''m not sure how Q3 does it, this is pretty much what I do though. I''ll have a wall, defined by a planed next to another wall, defined by a plane. I use spheres to use for collisions with players.
/
/
/ wall 2
-------------/ /---\
wall 1 | . |
\---/ <--- it''s a sphere, really

Now for crazy stuff. Seeing if the shpere and wall collide is basically the same as seeing if the shpere''s center collides with the walls if they are projected outward along their normals by the sphere''s radius.

sphere radius
[----]
/ /
/ /
/ wall 2
-------------/ / projected wall 2
wall 1 /
---------------/ .<---center of shpere
projected wall 1

Well that may seem a uselessly compley way to do collision detection, but we can use it to do collision responce too. We record the last position of the center of shpere and draw a line from the last position to the current position. If the line intersects one of those planes, a collision has occured. More fun ahead Now, assumming there is a collison(there is no collsion in my ascii drawing) We take the center point, which is inside the projected wall, and we shoot a ray starting with it along the wall''s normal and see where it intersects with the projected wall. This will be the new position of the center point of our shpere. By doing this, the sphere no longer intersect the wall(it just touches it), and this allows your chracter to slide along the wall if they hit at an angle.

Share this post


Link to post
Share on other sites
Bad thing about this technique is if your walls are at sharp angles to each other your projected walls will give collsions when they shouldn''t, I''m still working on that. I hope this helps, if you need to know how to get ray/plane intersections, etc, NeHe has a tutorial on it. Oh and if anyone has a better idea I''d love to hear it, I just came up with this way myself and am not sure it''s the best way to go. Too bad my ascii drawings didn''t show up right, guess I should have used tags.

Brad

Share this post


Link to post
Share on other sites
Ok I think I understand what you said, you say to project a wall along it''s normal, af far as the length of the bounding sphere''s normal. Then if the sphere collides, just relocate it along the new wall. If this isn''t right, then please correct me.

Second, you''ve applied this to a game or demo before right? If so, does it perform relatively fast?

Thanks

And if anyone else any input on collision response, then please don''t hesitate to send your thoughts.

En taro Adun!
Doom to all who threaten the homeworld!
*Protoss Zealot - Starcraft*

Share this post


Link to post
Share on other sites
You have the right idea. I have applied it to a game I''m working on, though all my walls are axis aligned, it''s a maze game. If you want to check it out it''s at:

http://braddog35.tripod.com/ratmaze.html

It''s far from finished but collision with walls is ok, and the camera wall collision works. The collision isn''t slowing the game down, but of course that''s because I only check for player-maze collisons on the block a player is on and blocks adjacent to the player If I didn''t have it set up that way, I''d use a Octree or something so I only have to check collision on a limited number of polygons. Right now my bottleneck seems to be the generation of the joint matrices. Anyways hope this helps.

Share this post


Link to post
Share on other sites
I''ve used the following technique and was really happy with it.

If you collide with the wall, find your depth of penetration (how far beyond the wall you are). Scale the normal of the wall you hit by the depth you just calculated. Move your position by the scaled normal and you should see yourself sliding along the wall. I also did this entire thing once more just to make sure the new position wasn''t outside of the wall (for instance, at a corner).

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!