Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Marcus · May 20, 2010 at 10:04 AM · destroyshootingexplosion

Trigger explosion on rocket

Hi

i need help with how do i trigger an explosion for my rockets when the time is up instead of them just being destroyed.

This is the code im using

var timeOut = 2.7;

var detachChildren = false;

function Awake ()

{
Invoke ("DestroyNow", timeOut);

}

function DestroyNow () {

 if (detachChildren) {
            transform.DetachChildren ();
 }    
 DestroyObject (gameObject);

}

I have downloaded the Detonator Package wich im trying to use for this...

Thanks for your help.....

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Lucas Meijer 1 ♦♦ · May 20, 2010 at 11:34 AM 0
Share

What's the question? Does this code not work? If not, what does it do? What did you expect it to do?

avatar image Marcus · May 20, 2010 at 07:39 PM 0
Share

the question is how do i start a explosion when the rocket is destroyed ins$$anonymous$$d of it just disappear.

avatar image qJake · May 20, 2010 at 09:32 PM 0
Share

@Lucas He wanted to know how to use the Detonator pack to instantiate an instance of one of the explosion prefabs that's included with the pack, though I agree, the question was pretty vague... took me awhile to decipher it. :P

avatar image Marcus · May 20, 2010 at 10:00 PM 0
Share

sorry about that

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by qJake · May 20, 2010 at 09:30 PM

Just add a reference to a Detonator prefab (from the pack), fill it in using the Inspector, and then instantiate it. It should go off right away if you didn't mess with anything in the Detonator settings.

// Fill this in using the Inspector
var explosion : GameObject;

Then, before you destroy the object, do something like this:

Instantiate(explosion, transform.position, Quaternion.identity);
Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Marcus · May 20, 2010 at 10:57 PM 0
Share

But what if you want the actual rockets (that im firing) to explode after the timeline that ive set to 2.7 seconds as you can see in the code. Right know when i tried your code the explosion takes place 2.7 seconds in to the game without me even having to fire the rockets

avatar image qJake · May 21, 2010 at 12:13 AM 0
Share

You have to put the explosion on the rocket object, so when the rocket is fired and explodes, the explosion gets spawned. This code won't work if it's not "on" the rocket.

avatar image Marcus · May 21, 2010 at 12:59 AM 0
Share

Ok now it works that when i press the shoot button the explosion and the firing of the rockets happens simultaneously, but i want that the explosion to occur at the end of the rockets "life cycle" when the rockets are destroyed. Sorry if i was unclear about what i needed..

avatar image qJake · May 21, 2010 at 04:36 AM 0
Share

So just do what you already did for the rocket, except do it for the explosion (using Invoke).

avatar image Marcus · May 21, 2010 at 05:07 PM 0
Share

Thank you i works now

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

No one has followed this question yet.

Related Questions

How to get rid of (cloned) particles after an explosion 2 Answers

i want to add fire shot at enemy gun explosion 1 Answer

Delete Explosion After 1 Second Script Not Working 2 Answers

problem with shooting killing script 1 Answer

How could i make it so that my bullets destroy after x amount of seconds? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges