Game Development Community

onCollision when hit by a specific object

by MichaelDom · in Torque Game Engine · 09/14/2010 (9:35 pm) · 1 replies

I'm trying to make an object dismount off of another when it has been hit by a particular group of objects [all members of "playerTouchClass"]. I know this should be pretty easy but I seem to be having a mental block with this please help. Crappy code:

function mountobj::onCollision(%this, %dstObj, %srcRef, %dstRef, %time, %normal, %contactCount, %contacts)
{


if (%srcObj.class = "playerTouchClass")
{
echo ("I GOT CALLED");
$mountHits = $mountHits + 1;
}

while($mountHits > 1)
{
%this.dismount();
}

}

#1
09/17/2010 (6:36 pm)
if (%srcRef.getClassName() $= "playerTouchClass")

Compare strings with the $= operator right now you're doing an assignment in the if statement if it were not a string you would want == not =