Game Development Community

Actor Explode to Gibs Question

by Justin Dobbs · in Torque 3D Professional · 05/02/2012 (3:02 pm) · 22 replies

Ok guys I have been messing with this issue for several seeks now and I am stuck. What i want to do is explode the actor into chunky bits when it dies. here is what i have so far and it works just the particle never plays, any idea's what i am doing wrong? I have testes the particle itself in the editor and it does work.
function Armor::onDisabled(%this, %obj, %state)
{
   // Release the main weapon trigger
   %obj.setImageTrigger(0, false);
   %obj.playDeathCry();
   %obj.playDeathAnimation();
   %obj.startFade(1500, 0, true);
   %particles = new ParticleEmitterNode()   
   {  
      position = %position;  
      rotation = "1 0 0 0";  
      scale = "1 1 1";  
      dataBlock = "BloodyGibsEmitterNode";  
      emitter = "bloodBulletDirtSprayEmitter";  
      velocity = "1";  
   };  
   MissionCleanup.add(%particles); 
   %obj.FlashlightDisable();
   // Disable any vehicle map
   commandToClient(%obj.client, 'toggleVehicleMap', false);

   // Schedule corpse removal. Just keeping the place clean.
   //%obj.schedule($CorpseTimeoutValue - 1000, "startFade", 1000, 0, true);
   %obj.schedule($CorpseTimeoutValue, "delete");
}
Page «Previous 1 2
#1
05/02/2012 (3:22 pm)
The local variable %position doesn't exist when you try and instantiate the ParticleEmitterNode.
position = %obj.getPosition();
#2
05/02/2012 (5:44 pm)
Works perfect thanks now to just tweak the explosion itself
#3
05/02/2012 (6:41 pm)
Cool. Those little gotchas like that still get me on occasion.

Are you using a combination of particles and the ShapeBase::blowUp() with PlayerDebris feature, or just particles alone?
#4
05/02/2012 (9:55 pm)
I have yet to understand how that Shapebase::blowUp() works so for now just particles. I have about 4 weeks of experience with Torque 3D lol so I am going one step at a time.
#5
05/03/2012 (11:12 am)
Does ::blowUP(); work with the player object and the playerDebris that is left over from Tribes?? I've never gotten the player to blow up and spit out it's debris. You know I can do it to any other shapeBase object, Michael!
#6
05/03/2012 (11:34 am)
I know I have tried many of the tutorials on this forum for it and none so far work but I could be just doing it wrong.
#7
05/03/2012 (9:27 pm)
I've gotten the player to blow up before. I just don't remember how I did it... whether it was a script solution or a source mod. Think it was something un-obvious, but simple. I know I've seen some videos that had the player blowing up as well... think one of them was by Guy Allard, not sure who else.

Just tried with the Full Template and nothing jumped out at me. Will have to investigate and maybe have a basis for another 'Damage and Destruction' Resource!
#8
05/03/2012 (10:21 pm)

recently i also was working to blow up my zombie.that is why i asked him about the video.
here is his answer:
Quote:
Torque has a system in place for semi auto generation of the parts from a correctly set up model. There's not much documentation on it, but this thread http://www.garagegames.com/community/forums/viewthread/125321 talks about it a bit.

to me most importent was:

semi auto generation

and

correctly set up model


i have asked about more details on that.but no answer so far

can anyone give me more information?

in unity there is a 50$ add on which automatically cut down any mesh.
was thinking is that possible in t3d!!!!!!!!!!!!!!
#9
05/04/2012 (2:06 am)
An example of a correctly set up model is the player_debris.dts found in art/shapes/actors/common, which is the pieces of the model you want to chunkify pre-broken into pieces -- Rex can probably give more details about that and it's hierarchy. The debris code can read this shape as a list of pieces and spew each chunk at a random direction. I outlined how to make use of it in one of my 'Damage and Destruction' Resources. In theory it should work for all Shapebase objects, but the Player class damage handling is overriding the Shapebase damage handling somewhere. I remember making it work for the Boombot on a project because the Boombot didn't have death animations, and then I forgot about the feature...
#10
05/04/2012 (3:52 am)
Ah! Simple enough. I found that old project (TGEa era) and what I had done was to make a console function to let us use blowUp() from script.
ConsoleMethod(ShapeBase, blowUp, void, 2, 2, "Explode an object into pieces.")  
{  
   object->blowUp();  
}
The sun is coming up and I'm sleepy -- so later today I'll convert that console method to the new DefineEngineMethod format and post up a Resource -- although the ConsoleMethod should still work as is. The player datablock, and the PlayerDebris are all setup and ready to go already, so with a two line source code change and a simple script call (%obj.blowUp()) you can make the player explode into many chunks. The player_debris.dts that I mentioned earlier is a holdover from Tribes2 and isn't textured but should still be good enough for demonstration purposes.
#11
05/04/2012 (4:11 am)
Super-Duper, Michael, that looks like a solution. I had figured that the damage--disable--destroy process was being overwritten by the Player code, just not able to figure it out. I'm an Artist afterall....and my thinking is; Player is a shapeBase object and it should fragment it's debris like the other datablocks.

And hhhmm.....the last posting by the Scott Burns seems to indicate that the 'blowUP' function has been 'fixed' and it should be working[that's my takeAway from the posting]. I'll have to go now and check in a 1.2 codeBase to see if 'fix' has been implemented.

Oh, no texture on the player_debris.dts file? LOL, here's the solution to that! Take ANY TribesII bitmap that is used by the Medium Male Player, and apply it to the 'player_debris.dts', ;) You'll be surprised[or not] that is fits the UV mapping perfectly....meaning the player_debris.dts file is directly from the Tribes asset tree. There's a bit o'history for ya.
#12
05/04/2012 (4:22 am)
Ya, checked that other link and there is a statement by Scott Burns that there is a 'fix' included in 1.1 Final. I entered a 1.2 codeBase and could not get Player object to 'blowUP()'. I'm figuring I need to go back and setup the damage--disable--destroy process again to get it actually to fire?

Checked in a 1.1 codebase and it did not work out of box. Still figuring the process needs to be rescripted to function. I seem to remember having to rescript a tad to get the process to roll...
#13
05/04/2012 (6:20 am)
I look forward to a solution in the mean time my plans are to workout the damage based trigger of said gibs after all we cant have an explosion into chunks from a simple pistol shot now can we :) . I have it mostly nailed down already just need to pop it into code and see what happens.

EDIT: All done with that little trick

in function Armor::damage just after

%obj.applyDamage(%damage);
I inserted
if (%damage > 70){
   %obj.startFade(15, 0, true); 
      %particles = new ParticleEmitterNode()     
   {    
      position = %obj.getPosition();    
      rotation = "1 0 0 0";    
      scale = "1 1 1";    
      dataBlock = "BloodyGibsEmitterNode";    
      emitter = "bloodBulletDirtSprayEmitter";    
      velocity = "1";    
   };
// Toss gibs function to come later here    
   MissionCleanup.add(%particles);
   }
and it works like a charm so now when you shoot them with just a pistol it does the normal death animation but if you shoot them with a rocket for example the poof into a bloody mist which will eventually be chunky meatness.
#14
05/04/2012 (7:59 am)
Quote:An example of a correctly set up model is the player_debris.dts found in art/shapes/actors/common, which is the pieces of the model you want to chunkify pre-broken into pieces

in irc i have asked about it.somebody may be steve answered that player class was not designed to work with debris.

then why is there a debris option in plyer datablock?
i have seen some properties of gui that have no effect on the control.

those are their only for inheritance?

#15
05/04/2012 (9:41 am)
@Rex: setting up the damage->disable->destroyed chain is what I thought should happen as well, but that didn't work for me. I've found the specific bit of player code that overwrites that, and because of it the Player has no concept of the destroyed damage state. I think it would be simpler to just expose blowUp() to the console.

@Justin: that's one way I would have suggested to use the blowUp() functionality. For the example I'll use for the Resource I'll simply check for a specific damageType. I've written an Improved PlayDeathAnimation Resource that determines a 'suitable' death animation based upon damage location/direction and/or damage type. I'm thinking that would also be a great place to drop a player blowUp() call into.

@ahsan: This functionality has always been there and was once available for direct use. The example shape indicated appears to have come from the Tribes 2 game which birthed the Torque engine. Over the years, I am assuming that someone at GarageGames decided that player debris was unneeded/unwanted/unused and decided to override the Shapebase damage handling for the Player class instead of removing it altogether. Object debris (which is slightly different from explosion debris as I explained in my resource that goes over it) is technically available for all Shapebase classes, but since the player class implements a work around against the 'normal' damage->disabled->destroyed damage state sequences the blowUp() function is not automatically accessible for players.
#16
05/04/2012 (9:49 am)
Wow i totally missed that resource and yes that is a much better way of doing it.
#17
05/04/2012 (2:21 pm)
Player Bits and Pieces Resource posted.
#18
05/04/2012 (2:42 pm)
Sweet thanks.. once I am done with the effect I will post a video of the carnage for all to enjoy!!


EDIT: Meat is served!!
#20
05/08/2012 (6:05 am)
Very nice!
Page «Previous 1 2