Skip to main content
gamedev.net
🔒 Locked

Collision response

Started by Hannesnisula Apr 24, 2009 at 2:00 AM 2 replies 1k views
Original Post
Hannesnisula
Hannesnisula
Let's say I've got a curved piece of terrain (just a lot of triangles with different angles) and I want to move forwared from the bottom of the hill, up the hill. If I move and I hit a triangle and got speed enough to further than the triangle I hit, how to hit and move along the next triangle? Of course I could just redo the collision detection/response until I've moved along my vector in each frame but isn't there some better/easier way to do this?
TythosEternal
TythosEternal
I'm assuming you're talking about 'walking' over a known terrain mesh, in which case I would recommend simply interpolating your current height and terrain slope from the current polygon and adjust accordingly. Am I understanding you correctly?

It also sounds like you might be having some conceptual issues with the "how to get from one mesh polygon to another" idea. One trick you could try is to write an inversion routine that accepts a x-y position and returns a handle to the terrain polygon that exists at that location. Bisection would be a quick way to go about it. That way, you'll always have a way to check the current polygon based on the object's / player's location, instead of having to jump from one polygon directly to another.
"Who's John Galt?"
Hannesnisula
Hannesnisula
I'm creating a collision detection/response system for my 3d game and I'm having trouble with the actual terrain collisions. I came up with something when I read your post:

Get starting and ending vector of the movement and check against objects in my BSP tree required for the line between those 2 vectors. So I can make sure I'm not intersecting anything, and then return a fraction value to calculate how far the object could move without collision.

But at the time I wrote that I thought of storing every triangle from the terrain just as the other objects' planes etc. I don't know if it's possible or if I'm just very confused, but I thought of getting the "safe" displacement on the XZ plane and then check what height I'd stop at, on the terrain.

But then again how would that work with walking inside a building with a floor higher than the terrain? At the moment I really need some idea of a working fast collision detection would work.

To answer your questions: Yes I meant walking on a terrain. Yes you understood me correctly.

I don't understand the last part of what you wrote.

I also just thought I would then have to somehow check if I was passing over some triangle of the terrain which would have an angle too high to being able to walk over.

I actually just need some kind of complete routine for a fast but still good way to do the whole collision thing.

Topic Locked

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

Sign in to reply to this topic.