Sparky Collision Planetary Gravity help

Flamesilver 101 Feb 22, 2011 at 00:35

I’m having trouble with Planetary Gravity and Collisions in a Zero-G Space Flight game environment. I’m new to Dark GDK and SC_Collision.

I figured for Planetary Gravity, I’d use an invisible sphere that represents the Gravity Field, and check for Ship (or RenderableObjects in general) inside of it using something like SC_objectCollision. My problem is, when multiple objects are inside this field, I can’t just use SC_objectCollision( object#, 0 ) to give me a list of collisions like I can with SC_multipleRayCast()

I have to do a:

SC_objectCollision (obj, 0) // check if anything is in the gravity field

for (…) {
// check every object in space to see if it collided

Doesn’t seem very efficient. Any ideas?

Thanks in Advance,


3 Replies

Please log in or register to post a reply.

geon 101 Feb 22, 2011 at 11:19

That’s pretty much how it’s done.

You can make it more efficient with spatial indexing and whatnot, but the basic algorithm remains the same.

Reedbeta 167 Feb 22, 2011 at 18:35

If the gravity field is spherical, checking whether an object is inside it is just calculating the distance from the object to the center and checking if it’s greater or less than the radius. That’s very cheap. I wouldn’t worry about the performance unless you have at least 1,000 objects; then it might be worth looking at.

Flamesilver 101 Feb 24, 2011 at 17:50

Thanks for all your help. I’ll start checking them 1 by 1 and hope for the best.