Collision in a Simple World

Started by
1 comment, last by Rasmadrak 18 years, 8 months ago
We all know about gravity and spheres and drama like that, it's all well and good. What I need is something much more simple. I'm working on doing a click to move 3d heightmap engine, kinda RTS style. There is no jumping and falling off cliffs and such, I basically need units to follow the terrain. Right now I just cast a ray downward on the map and have the unit get placed at the intersect point. That's all well and good, but it has it's own drawbacks. For example. I'd like the ability to have bridges where a unit can walk over or under the bridge. A simple ray cast won't figure out which to choose. Etc. Anyone do anything similar with a simple collision engine? Or know of any articles on a simple one? Thanks in advance.
Advertisement
I haven't done anything specifically like what you describe, so this is just speculation.

One solution would be to simply include other objects other than the terrain in your raycast, and consider the first hit to be the object the character is standing on. This would be an easy and natural extension of your current system.

This obviously won't work if, say, a character can walk off a bridge. Your current method would simply 'snap' the character unnaturally from the bridge to the ground. If you know there won't be any such discontinuities, you're probably good to go.

An easy extension to your current method would be for the character to 'fall' toward the intersection point rather than snap to it, which would support walking off bridges and such. The disadvantage would be that the raycast is an approximation and there would likely be some clipping when walking off of a cliff or bridge.

Other problems that might arise include a tall object going under a bridge and colliding with it; the current method would miss this and other similar situations.

In this case I would implement a simple sphere-based collision detection and response system. If the displacements of your objects are small (likely in an RTS setting), you could get away with a static rather than swept test, which is fairly easy to implement and I think would produce natural and satisfactory results.
my approach is boxes.. :)

I've done like you say, my units are aligned to the terrain, but before the "gravity" function takes place, another check against the possible collision boxes in that region is checked.. if it collides with one, reposition the unit.

this works rather well, dont know how it performs with larger numbers of collision boxes and/or units...

"Game Maker For Life, probably never professional thou." =)

This topic is closed to new replies.

Advertisement