Game Development Community

Self Destruct -> explosionEffect not available

by David Janik-Jones · in Torque Game Builder · 07/23/2007 (10:12 am) · 12 replies

I'm tinkering with the first behaviour tutorial and trying to make it so what when the sprite running away from the mouse collides with it's world boundaries it self destructs. No problem adding the necessary two behaviours, but the Self Destruct behaviour will not let me select an explosionEffect. Only "None" is shown in the pull down menu. And idea why?

Also, have there been any behaviours yet created (on those hidden forums for purchasers) that have been shared to keep track of time (a timer counting up or down and displaying in a text object) or score?

David

#1
07/23/2007 (12:32 pm)
Hey there. The self destruct behavior is looking for a particle object. You have to create a particle effect or use a preexisting one, drag it onto the scene, and give it a name under "Scripting." It will then show up in the dropdown menu. Object fields are looking for named objects that exist in your scene--they will use these objects as templates for whatever they're doing--ie, they'll use the particle effect as a template that it will clone each time the object explodes.

Also, there is a counter behavior available on the TDN that updates a text object. :)
#2
07/23/2007 (1:05 pm)
Thanks Melissa. I have no luck. I dragged out the cartoon_big_explosion (both onto the actual gameplay area and also off to the side), named it under Scripting "explodeMe" and also saved it as it's own particle effect. The drop down menu works fine ... I can now select "explodeMe" as the effect I want. But it does not get called even though the Self Destruct Behaviour is set up correctly.

Thoughts?
#3
07/23/2007 (1:52 pm)
Did you set the object's world limit as well? Under world limits, you also have to check the "callback" box so that it knows to trigger the onWorldLimit callback.

Edit: also, may want to set the "fuseTime" to zero so that it explodes right away.
#4
07/23/2007 (1:57 pm)
I did set it to 0 actually and I know it's receiving the collision with it's world boundary as it destroys itself.

Picture 1 here shows the Edit settings for the sprite, the Picture 2 one shows the settings for the particle effect that sits slightly off stage.

http://www.artspin.com/Picture1.png

http://www.artspin.com/Picture2.png
#5
07/23/2007 (2:36 pm)
I tried it out and it seems to be working. Hmm. Is your world limit response set to "kill?" Because that would destroy the sprite too. Just to confirm...the "callback" box is checked?

i189.photobucket.com/albums/z88/melissaniiya/example.jpg
#6
07/23/2007 (5:04 pm)
The thing I was missing was the NULL Limit Mode. It's working now, thanks Melissa.

Now to tinker to try to replicate the respawn thing in Asteroids level.

EDIT LATER --

It's working now too. Excellent progress so far. Melissa, if I could ask one more favour ...

http://www.artspin.com/Picture3.png

I have four collider objects around the outside of the screen that cause 1 point of damage when the ship hits them. 5 ship lives (with 1 damage) so that the ship respawns each time for 5 times when it hits the "walls".

But I have an odd behaviour going on ... after the ship has bumped into, say, the LEFT wall and blows up and respawns, every time I hit that same (left) wall it no longer registers 1 points of damage/destroys the ship. This happens for all of the walls.

Can you enlighten me as to why that might be?

Also, how to you force the ship to respawn in a specific area of the screen? (Although I set the Invincible variable to 3.000 to elimnate the "still touching the wall destroy immediately again" problem).
#7
07/23/2007 (6:53 pm)
If the wall blows up and respawns, it might not have the Deals Damage behavior added to the spawned copy. How are you respawning/what behavior are you using to respawn? Generally you'll have to have %obj.cloneWithBehaviors somewhere in the respawn, or add the behaviors manually with %obj.addBehavior(nameOfBehavior)...

As for the ship respawning...again, can I see the code that you're using/or the name of the behavior you're using if it's one of the default ones?

You'll want to go into the game/data/behaviors folder and open the script file for that particular behavior. Then, you can add something like this:

%newObject.setPosition("0 0");
Or whatever coordinates you like. I can be a bit more specific when I see the code you're using or know what behavior you have set on your ship. :)
#8
07/23/2007 (6:58 pm)
The four "walls" are not set to destroy themselves when they Deal Damage (i.e., deleteOnHit is not checked). And I know they are still there because the sprite can keep bumping into them (the edge of the sprite's World Boundary being outside these four "walls" and the edge of the screen). Maybe it's one of the other collision modifiers on the "wall" objects I've got set wrong.

The ship respawning is simply the Takes Damage behaviour ... the same one that appears to be on the spaceship in the Asteroids behaviour example level.
#9
07/23/2007 (7:50 pm)
I'm really not sure why the walls aren't functioning properly, might be on the Takes Damage side. On mine, I set the health to 1 and lives to 5, seemed to work fine. I can't recreate it, so...not sure. If it's still giving you trouble, you could zip up your project file and email it to me, or perhaps tell me what your ship's behavior settings are...hmm.

As for the respawning at a certain location, this is easy to do and a great way to play around with some simple scripting. Open the takesDamage.cs file in your behaviors folder, and add the bold line:

%template.addBehaviorField(explodeEffect, "The particle effect to play on death", object, "", t2dParticleEffect);
   [b]%template.addBehaviorField(respawnLocation, "The location where object respawns", point2F, "0 0");[/b]
}

This line creates a field called "respawnLocation" in your behavior that'll show up in TGB. It's a "point2F" field--one that takes a position.

Next, scroll down and fine the function TakesDamageBehavior::spawn and add this line to it:

%this.owner.setPosition(%this.respawnLocation);

When the player respawns, this line will set its position to whatever position you enter in the respawnLocation field. Save the takesDamage.cs, then reload your project and the field will show up in the takesDamage behavior, and you'll be able to enter whatever coordinates you like...
#10
07/23/2007 (8:08 pm)
Thank you for all your help Melissa. If you eve rneed help with Unity, let me know. :-)

The sprite now respawns fine, once I figured out how the coordinate system worked. Thanks. The file is zipped up at http://www.artspin.com/BehaviorPlayground.zip and the level I made was RunFromMouse. The "wall" problem may have something to do with the fact that I simply created the first, then copy/pasted the others from that first one.

Maybe?

Thanks for taking the time.

David
#11
07/23/2007 (9:44 pm)
Hmm just realized you're using a mac version, sorry it took a little while to figure out how to open the file on this end. If I try out Unity, will know who to call, many thanks heh.

I tinkered around in the level. First, you probably want to set the collision response of the walls from bounce to clamp so that they don't move when the ship hits them... I think this might be part of the problem with them not working any more, too. It's possible that it's processing the bounce first instead of the damage. I also turned physics off the ship, this may or may not have done anything. I can't seem to recreate it consistently, so hmm...
#12
07/24/2007 (4:50 am)
Thanks Melissa for all your help.

Set the "walls" to Clamp, made sure they had any Physics or turned off and made them Immovable as well. Turned off physics on the sprite as well. I'll give a look this morning but will post the whole project to open scrutiny later (I'm off today visiting friends at an organic farm) today if I have no further luck.