x


Setting timed detonations with the detonator kit

Well I imported the detonator package, really liked it, and wanted to use it for force power type things, for which it worked well. The problem was I also wanted it to do some cool effects for animations, like ex/ a pic of the earth having one nuke going off on it, then 4 more, then a whole bunch of them, but how do I set a time constraint, so that they will go on after x seconds?

At the top it mentions explode() can set it off after a time, but I have no idea how to format that. I think it may be simplier than actually rewritting an addtional code.

more ▼

asked Jun 26 '10 at 04:38 AM

jack 1 gravatar image

jack 1
464 31 40 56

Why did you post the Detonator code? We all know what it looks like, there's no need to clutter up your post, you could have just asked how to use it.

Jun 26 '10 at 06:48 PM qJake

Still new to this type of environment

Jun 27 '10 at 12:41 AM jack 1
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

You can write a script to do it, using one of the following two methods:

Coroutines

Use a coroutine, something like this:

void Start()
{
     StartCoroutine(BlowStuffUp());
}

IEnumerator BlowStuffUp()
{
     yield return new WaitForSeconds(5);
     // Spawn explosion here
     yield return new WaitForSeconds(3);
     // Spawn more of them here
}

Invoke

Use Invoke(), like this:

void Start()
{
     Invoke("Detonate", 3);
}

void Detonate()
{
     // Spawn explosion(s) here.
}

Edit:

Since you edited your post and asked yet another question, you use Detonator simply by instantiating one of the prefabs it gives you. When a detonator object is spawned, it explodes, and then it automatically cleans itself up when it's done, so all you need to do is Instantiate() one of the prefabs.

more ▼

answered Jun 26 '10 at 06:38 AM

qJake gravatar image

qJake
11.6k 43 78 161

But... what if I want Javascript? Where's the Pseudocode? :)

Jun 26 '10 at 03:53 PM Cyclops

Don't worry that was only half my question, I just wanted a start :)

Jun 26 '10 at 04:03 PM jack 1
Jun 26 '10 at 04:08 PM Cyclops

haha I know that, but the point was even still I didn't ask the complete question, which is an alternative to pseudocode, having users be limited to one part of their questions answered properly, so less knowledgable programmers would not be confused, but would have a start instead to work from.

Jun 26 '10 at 05:04 PM jack 1

@Cyclops Haha... I'm not fond of it, I just wanted to start a discussion to see if it would be useful here ;) Still, touch. :P

Jun 26 '10 at 06:41 PM qJake
(comments are locked)
10|3000 characters needed characters left

Uncheck the explodeOnStart option, and then ,in your code, call the Explode() method whenever you want.

more ▼

answered Nov 23 '12 at 03:33 PM

Symyon gravatar image

Symyon
23 1

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x53
x16

asked: Jun 26 '10 at 04:38 AM

Seen: 1246 times

Last Updated: Nov 23 '12 at 03:33 PM