explosion with radius damage


I need your advise before trying to code what I want to do.

In my game (space game), there is a weapon called a Timed mine. This mine explode when it touch something but also explose after 3 second of life.

I’m not sure how to code the last one. Is there a way in Panda3D to know what is in a certain radius of a point? All my other objet have a collision sphere so maybe it can help?

If it’s possible, I would want to do more damage if the other objet a nearer and less damage if they are far from the explosion. But this is not a vital specification.

I have a strange idea with collision sphere but I want to ask your idea before trying mine!



you could probably use another bigger collision spheres node
for the lesser damage range. There has to be an interval code
for time and not movement, for the three second delay,
but I don’t know what it is yet :slight_smile:

use a collisionsphere.
if collision occurs take the list of colliding nodes you can use several methods to get the deepth of the 2 colliding spheres.
check http://panda3d.org/apiref.php?page=CollisionEntry
it offers a method to get a point which can be used to calculate penetration deepth,
or use the get from/into nodepath calls to get the 2 nodepath and do something like that
damage = ( sphereSize - fromnodepath.getDistance(intoNodePath) ) * someValue
guess you have to find a good forumalr yourself , based on your sphere sizes and damage ranges.

Thanks a lot!

That was the idea I had but wanted to be sure that is was the better way to do it!

Greatings from Quebec with the biggest snow storm in the last 40 years!