Exploding player when killed
by Chris Mooney · in Torque Game Engine · 12/17/2007 (10:55 am) · 3 replies
I would really appreciate any help anyone could give me.
I want to make the player explode when killed. Ive noticed code in player.cs that seems to be similar, I'd like to go for a debris type thing as with the crossbow explosion. I do remember it being used in a TGE project I worked on way back (probably 3 or 4 years ago), but I have no recollection of how we did it lol and really im just looking to make the player explode with any type of death.
Any help would be great!
Chris
I want to make the player explode when killed. Ive noticed code in player.cs that seems to be similar, I'd like to go for a debris type thing as with the crossbow explosion. I do remember it being used in a TGE project I worked on way back (probably 3 or 4 years ago), but I have no recollection of how we did it lol and really im just looking to make the player explode with any type of death.
Any help would be great!
Chris
About the author
#2
Thanks for the reply, I will give that a try right away :), been out of town and forgot to check the thread :D. I'll reply on how it goes.
Chris
12/21/2007 (3:54 pm)
Hey Nathan, Thanks for the reply, I will give that a try right away :), been out of town and forgot to check the thread :D. I'll reply on how it goes.
Chris
#3
Thank you! I'll have to credit you with the help :)! Im assuming the explosion data is from the player debris stuff from looking at the effects :D.
Thanks
Chris
12/21/2007 (4:14 pm)
Works perfectly :D!Thank you! I'll have to credit you with the help :)! Im assuming the explosion data is from the player debris stuff from looking at the effects :D.
Thanks
Chris
Torque Owner Nathan Martin
TRON 2001 Network
So I went digging into the engine source code to see how I can add that functionality to the scripting language back. Here is how I ended up making it work:
Edit tge/engine/game/shapeBase.h and locate:
move it from being a protected to a public to another line, there is a public: keyword further down where you found the blowUp virtual prototype, just move the line below that. Be sure to save that change.
Next, edit tge/engine/game/shapeBase.cc and paste this code at the bottom of the source file:
ConsoleMethod( ShapeBase, blowUp, void, 2, 2, "Causes the object to explode into pieces.") { object->blowUp(); }This makes the blowUp() function exposed to the scripting language for shapeBase objects. Now to make use of the blowUp() function, open up tge/example/
Change this block of code
to this one
// Schedule corpse removal. Just keeping the place clean. // %obj.schedule($CorpseTimeoutValue - 1000, "startFade", 1000, 0, true); for(%i=0; %i<4; %i++) %obj.blowUp(); %obj.startFade(50, 0, true); %obj.schedule($CorpseTimeoutValue, "delete");There, next time your player dies it should provide a nice explode into pieces effect. The for() loop there is to cause it to blowup the same debris model four times to get a four times bigger exposion effect.
Almost forgot, make sure to do a recompile of Torque in order to see blowUp() accessible to the scripting language, do it for both Release and Debug (if you frequently use both to develop and test your game).
:)