Applying damage to objects with projectiles
by Hogie · in Technical Issues · 02/27/2008 (2:32 pm) · 2 replies
Hello,
I am trying to apply damage to a static shape when a projectile collides with it, and was wondering if anyone could give me some advice. I am new to torque script, and so far, I only have a datablock set up for the static shape that sets its max damage, disabled level, and destroyed level. If anyone could point me in the right direction from there, it would be very much appreciated. Thanks in advance,
Hogie
I am trying to apply damage to a static shape when a projectile collides with it, and was wondering if anyone could give me some advice. I am new to torque script, and so far, I only have a datablock set up for the static shape that sets its max damage, disabled level, and destroyed level. If anyone could point me in the right direction from there, it would be very much appreciated. Thanks in advance,
Hogie
#2
thanks for the response Nathan. I actually found a few examples that use what looks like a callback (not sure if this is called a callback) that executes when a shapeBase derived object is struck by a projectile. I didn't look into why this function is called, but I assume it's somewhere in the projectile code. It works for my purposes though. The code I used looks like this (TargetObject is the datablock of my object):
function TargetObject::Damage(%data, %obj, %sourceObj, %pos, %damage, %damageType){
%obj.applyDamage(%damage);
%obj.playThread(0, "targetExplode1"); //plays explode animation as soon as it is damaged
}
03/03/2008 (4:38 pm)
Hey,thanks for the response Nathan. I actually found a few examples that use what looks like a callback (not sure if this is called a callback) that executes when a shapeBase derived object is struck by a projectile. I didn't look into why this function is called, but I assume it's somewhere in the projectile code. It works for my purposes though. The code I used looks like this (TargetObject is the datablock of my object):
function TargetObject::Damage(%data, %obj, %sourceObj, %pos, %damage, %damageType){
%obj.applyDamage(%damage);
%obj.playThread(0, "targetExplode1"); //plays explode animation as soon as it is damaged
}
Torque Owner Nathan