Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Object inside Zone detection - Fulcrum Physics or Sparky's or Built-in?

Author
Message
iSilver
13
Years of Service
User Offline
Joined: 20th Feb 2011
Location:
Posted: 19th Mar 2011 05:43
I require an easy and efficient way to detect whether or not objects are in a zone for a Zero-G Space game using 3D but with motion limited to 2D ala Space War/Star Control.


This would be used to implement such things as:

- Planetary Gravity: There can be multiple Planetary objects exerting gravity on any object within its gravitational field (a sphere). When an object is detected inside a zone gravity force is applied to it according to the distance between object and Planet

- Explosion: Basically the reverse of gravity. If an object is within a certain spherical range of an exploding missile or ship, repulsion force is applied to it according to the distance between object and explosion point.

I'm already using Fulcrum for Physics, so I'm reluctant to add Sparky's Collision because Fulcrum could already handle the other contact data such as actual physical interactions (ship hitting ship, ship hitting planet, ship hitting bullets, etc). However, I don't yet know of a way I can make an object that is pass-through so it won't affect objects colliding with it, and yet reports it as a contact so I can handle the "collision" (I guess intersection is the right term here).

Any advice?
Noley
13
Years of Service
User Offline
Joined: 13th Dec 2010
Location:
Posted: 20th Mar 2011 06:15
Well for explosions you could run a check to get the distance of nearby ships and if they are within a certain distance you could push them away

and for the gravity you could have it using specific XYZ co-ordinate ranges like

if (X > 2 && X < 123 && Y > 55 && Y < 500 && Z > 3 && Z < 300)
{
gravity_planetName..
}

Those are fairly simple ways of doing it, one could probably come up with plenty of alternatives but that is probably how I would do a simple zone-specific effect such as gravity or explosions.

Hope this helps
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 20th Mar 2011 13:28
What Noley sais above will work great for box shaped zones, for gravity and explosions you can just use a sphere shaped zone which is even easier.

Just calculate the distance between the two objects, if its less than a certain value then apply the force.

I think you can work out how much force to apply on each axis depending on the distance just along that particular axis.

iSilver
13
Years of Service
User Offline
Joined: 20th Feb 2011
Location:
Posted: 20th Mar 2011 14:37
Cool. I just figured there might be a more efficient way built into dGDK or Fulcrum. But you guys are right, it's simple enough to do by code. Just didn't want to have to iterate through every object for each zone / explosion. I guess I'll have to figure out a clever way to check all zones against all objects at the same time.

Thanks,

Flamesilver
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 20th Mar 2011 14:46
Yeah, PhysX does have force fields which would be easier and slightly more efficient but I have not added them to Fulcrum.

I doubt I will be adding any more features as I am working on a total re-write which will have more or less everything Physx offers.

Login to post a reply

Server time is: 2024-06-27 22:03:05
Your offset time is: 2024-06-27 22:03:05