spawn (object "X") if (item "X") is thrown?
by deepscratch · in Torque Game Engine Advanced · 02/22/2009 (8:40 am) · 1 replies
hi there,
what I'm trying to do here is spawn something of a class that is different to the item class, in the same position as the item was when thrown.
the scenario is this:
player has a weapon with a clip, he gets killed, on disabled he throws the weapon and the clip as 2 diferent items.(this I have working fine)
now the tricky bit
I'm trying to get the weapon item, on being thrown, to change from an item class to a rigidshape class(or physX class, even better),from the same position and velocity as the item at the moment of throw. the model would be the same model, but now be a different class.
the clip would not change class at all.
why am I trying to do this?
if you have a weapon in your hands, you can pick up the clip, but you wouldn't want to pick up the weapon as well. the weapon would become a physics object(rigidshape) that could now interact with the world, projectiles, players kicking it or vehicle riding over it(you get the idea)
this could be extended to equipment (helmets, backpacks, whatever), that also get dropped(thrown) on the poor fellows demize, (think about the dead player, who was a corpseObjectType, but is now a rigidshape, shoot at him and his body now recieves impulses and moves about.
so...
does anyone have any clue as how to spawn an object of a different class to the item class at the time and place of the throw??
what I'm trying to do here is spawn something of a class that is different to the item class, in the same position as the item was when thrown.
the scenario is this:
player has a weapon with a clip, he gets killed, on disabled he throws the weapon and the clip as 2 diferent items.(this I have working fine)
now the tricky bit
I'm trying to get the weapon item, on being thrown, to change from an item class to a rigidshape class(or physX class, even better),from the same position and velocity as the item at the moment of throw. the model would be the same model, but now be a different class.
the clip would not change class at all.
why am I trying to do this?
if you have a weapon in your hands, you can pick up the clip, but you wouldn't want to pick up the weapon as well. the weapon would become a physics object(rigidshape) that could now interact with the world, projectiles, players kicking it or vehicle riding over it(you get the idea)
this could be extended to equipment (helmets, backpacks, whatever), that also get dropped(thrown) on the poor fellows demize, (think about the dead player, who was a corpseObjectType, but is now a rigidshape, shoot at him and his body now recieves impulses and moves about.
so...
does anyone have any clue as how to spawn an object of a different class to the item class at the time and place of the throw??
About the author
email me at medan121@gmail.com
Torque Owner deepscratch
DeepScratchStudios
1:created new physx datablocks for the items, pointing to the same models that where items.
2:created a new function in item.cs called "createpxItem" that creates a new PhysXActor object.
3: created a schedule that spawns the physX item in the position and rotation of the old item at the moment of the characters death and pops the old item at the same time.
works a treat, couldn't help laughing the first time it worked as the character died, throwing his arms in the air, and the weapon went flying off, landed, bounced and rolled away.
now just to tune the throw force, if you are using physx, you'll know how sensitive the actors are to impulses, the weapons flew a good 20 meters into the air, spinning away gently as if they weighed 0.5 kilos.
so now to try the same thing with creating vehicle pieces that'll fly off when a vehicle gets destroyed. fun.
hey, that means physx debris is also on the books (think glass from shot out windows and bottles, chunks of rubble that'll hit and damage you, shit, my mind is racing here, no sleep tonight.
if anyone is interested in this I'll make a vid of it in action, and yes, I'll share how I did it