Game Development Community

getting physx objects to apply damage?

by deepscratch · in Torque Game Engine Advanced · 03/20/2009 (4:06 am) · 2 replies

hi there,
how would one go about getting a physx object to apply damage to a player/vehicle/aiplayer/whatever?
this is the scenario:
the wall of physx boxes; when my grenades go off near the wall, the boxes fly off in good old physx style, but when they hit other objects, they dont damage them.
how to get those flying physx boxes/whatevers, to apply impact damage to player/vehicle/aiplayer/whatever?
thanks.

#1
03/20/2009 (7:37 am)
How about using the collision call to find out how fast the object is moving if it hits a damageable object (like a player). Over a certain delta/velocity give X damage?

[psuedocode]
function YourObject::onCollision(%this,%obj,%col)
{
if (%obj.getState() $= "Dead")
return;

if (%col.getClassName() $= "damageable" || %col.getClassName() $= "Player")
{
%col.damage=%obj.getvelocity;
}
}
[/psuedocode]

Something like that ... only better.
#2
03/20/2009 (11:29 am)
@deepscratch, you'll have to check out the PhysX contact notification system. You'll want to set it up and call back to the PhysX actor's Torque object so you can do as Steve mentions.