Game Development Community

Multiple Objects doing different things?!

by Remorseless · in Technical Issues · 05/26/2010 (12:38 am) · 0 replies

I am trying to do the following.

I have objects that kill the player upon collision contact. I want most of these to simply kill the player and that be. But i also want a couple of these to be "special". I want them to kill the player, BUT they can be "triggered" by other actions.

It seems i cant have them be in the same class as others. I tried doing the following.

//Trampoline Script

function Trampoline::onLevelLoaded(%this, %scenegraph)
{
//set the Trampolines name
$GTrampoline = %this;
alxPlay(Drone);
}


function Trampoline::onCollision( %srcObj, %dstObj, %srcRef, %dstRef, %time, %normal,
%contactCount, %contacts )
{
if(%dstObj.class $= "player")
{
%srcObj.safeDelete();
%dstObj.setLinearVelocityY(-20);
alxPlay(TrampolineHit);
alxStop(Drone);
}
}

//TrampolineSpecial1 Script

function TrampolineSpecial1::onLevelLoaded(%this, %scenegraph)
{
//set the Trampolines\Trigger name
$GTrampolineSpecial1 = %this;
alxPlay(Drone);
}

function TrampolineSpecial1::onCollision( %srcObj, %dstObj, %srcRef, %dstRef, %time, %normal,
%contactCount, %contacts, %object )
{
if(%dstObj.class $= "player")
{
%srcObj.safeDelete();
$GTrampolineSpecial1.safeDelete();
$gkillobjectspecial.safeDelete();
%dstObj.setLinearVelocityY(-10);
alxPlay(TrampolineHit);
alxPlay(WooHoo);
alxStop($Drone);
}
}

both of these are in the "killgroup" script

//KillObjects Script

function KillObject::onLevelLoaded(%this, %scenegraph)
{
//set the Objects name
$gkillobject = %this;
}

//KillObjectSpecial1 Script

function KillObjectSpecial1::onLevelLoaded(%this, %scenegraph)
{
//set the Objects name
$gkillobjectspecial1 = %this;
}


It seems that this is obviously not the way to go. As when one gets hit, it stops the others from causing death when they are hit. Is the only way to do this a "simset" or is there another way? Can i put these in different script files and that would work fine? Or would that be really ineffecient?

thanks for the help so far helping such a n00b out.