If/else not evaluating properly?
by Jason Swearingen · in Torque Game Builder · 08/13/2005 (2:51 am) · 3 replies
This is using the "Basic Tutorial" torquescript code.
for my enemy fxSceneObject2D's i add the .shipType field and set it to "enemy"
then in the OnCollision() function i check for this, and if it's an enemy, i make a big explosion.
However, the problem is a big explosion is ALWAYS triggered, meaning that the IF is always evaluating to true... any help?
for my enemy fxSceneObject2D's i add the .shipType field and set it to "enemy"
then in the OnCollision() function i check for this, and if it's an enemy, i make a big explosion.
However, the problem is a big explosion is ALWAYS triggered, meaning that the IF is always evaluating to true... any help?
function fxSceneObject2D::onCollision( %srcObj, %dstObj, %srcRef, %dstRef, %time, %normal, %contactCount, %contacts )
{
// Create an explosion for the collision that just occurred
%toLookFor = "enemy";
%foundValue = %dstObj.shipType;
echo("========");
echo(%foundValue);
if(%foundValue == %toLookFor )
{
createBigExplosion( %dstObj );
}
else
{
createExplosion( %dstObj );
}
Torque Owner Toby Mckenzie
if (%foundValue $= %toLookFor) { createBigExplosion(%dstObj); } else { createExplosion(%dstObj); }