Thread not found

Game Development Community

New instance of object upon collision

by Henry Leung · in Technical Issues · 04/12/2008 (3:02 pm) · 1 replies

Hello I'm new to Torque, right now I'm trying to have a new object spawn when I collide into something.

I'm going to use the demo tutorial for this. Basically this is what I have so far,

function TorqueLogoItem::onCollision(%this, %obj, %col)
{

if(%col.getClassName() $= "Player")
{
%client = %col.client;
%client.score++;
commandToClient(%client, 'SetScoreCounter', %client.score);

%obj.delete();
%logoCount = logo.getCount();
echo(logo.getCount());

if(%logoCount > 0)
return;

%newObj = new InteriorInstance(house2) {
position = "0 0 0";
rotation = "1 0 0 0";
scale = "1 2 2";
interiorFile = "~/data/interiors/box.dif";
};

//echo ("RAWR");
}
}

So basically, right now I have 2 logos on the field, and after I collect them the console will load the new instance, but how do I get it to appear on the field upon the 2nd collision.

Edit* Ok nvm, it seems like it DOES appear, but it crashes my torque instead. It doesn't crash when I try finding it in world editor mode. If possible, can someone help me out figure this little problem out? It'd be great, thanks.

About the author

Recent Threads


#1
04/16/2008 (9:03 pm)
Adding a dif object could be problematic, as it has to be lit, and might possibly be the cause of the crash. Could you use a DTS? I spawn dts's from script constantly with no problems.