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.
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.
Torque Owner Lee Latham
Default Studio Name