Sparky Collision Planetary Gravity help

C6cb6c90c411f01492653729e7548a50
0
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,

Silver

3 Replies

Please log in or register to post a reply.

820ce9018b365a6aeba6e23847f17eda
0
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.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 168 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.

C6cb6c90c411f01492653729e7548a50
0
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.