Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Grady · Jul 07, 2011 at 08:38 AM · collisionobjectexplosionground

How to make an object explode?

Hey guys,

I am making an aircraft game, and i want it so that when the aircraft hits the ground, it explodes.

I have downloaded the explosion framework: http://unity3d.com/support/resources/unity-extensions/explosion-framework, but i can only seem to get the explosion to work after a ceratin amount of time, does anyone know of a tutorial or a method in which i can use it to make the explosion occur on collision.

Or if the explosion framework can't do this, is there another way to make explosions????

Thanks

-Grady

Comment
Add comment
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

2 Replies

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

Answer by FourSheds · Jul 07, 2011 at 10:21 AM

Hi

Assuming you already have the Detonator script attached, and 'Explode On Start' is disabled, then you can call Detonator's Explode() function within your OnCollisionEnter() method like this:

 gameObject.GetComponent("Detonator").Explode(); 

Comment
Add comment · Show 4 · 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 Grady · Jul 07, 2011 at 11:40 AM 0
Share

ok, thanks, that works, but after that line, i put: Destory(gameObject); so my script looks like:

function OnCollisionEnter(collision : Collision){ if (collision.gameObject.tag == "terrain"){ gameObject.GetComponent("Detonator").Explode(); Destroy(gameObject); } }

but that just destroys the object and no explosion goes off....

I also find the below script on the internet:

// A grenade // - instantiates a explosion prefab when hitting a surface // - then destroys itself

var explosionPrefab : Transform;

function OnCollisionEnter(collision : Collision){ // Rotate the object so that the y-axis faces along the normal of the surface var contact : ContactPoint = collision.contacts[0]; var rot : Quaternion = Quaternion.FromToRotation(Vector3.up, contact.normal); var pos : Vector3 = contact.point; Instantiate(explosionPrefab, pos, rot); // Destroy the projectile Destroy(gameObject); }

You just attach it to the game object and then you put the explosion prefab that you want in their. That works too, but when my aircraft hits the ground, it destorys and the explosion plays, but the explosion is a little bit of center, so the explosion plays in a different place to where the aircraft actually crashed....

If you can fix the above script then that would be good, but if you have any ideas for the first one, that would be great too!!!!

Thanks

-Grady

avatar image FourSheds · Jul 07, 2011 at 12:51 PM 0
Share

Not sure about the 2nd script without trying it, but in the first method, you could put a time delay: Destroy(gameObject, 5). Or you could put the Detonator script on an empty game object in your scene (that doesn't get destroyed) and call Explode() via that.

avatar image Grady · Jul 08, 2011 at 06:14 AM 0
Share

thanks!!!!

avatar image FourSheds · Jul 08, 2011 at 06:24 AM 0
Share

You're welcome! Hope this answered your question, hint, hint ;)

avatar image
0

Answer by Ailos · Jan 12, 2012 at 08:07 PM

hello! I'd like to know , how can I do, that the explosion slowly dissipate? not, suddenly dissapear!

thanks a lot!

Comment
Add comment · 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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Detonation of an object on collision of character.... 1 Answer

Can an object to transfer to another as it increases your speed? 1 Answer

How can I do a collision check with a specific Object? 3 Answers

Object only explodes when it collides with certain object, not all rigidbodies. 2 Answers

how to check if one object is colliding with another 1 Answer


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