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 Jammer3000 · Feb 27, 2013 at 09:48 PM · destroyparticlesystem

How to emit particle from a collision?

Hi I have some code(the code below) and it works great, but I need it to explode where ever the sphere ends up. The game is I have a hammer. And a sphere as the enemy so whenever the player hits the sphere with his/her hammer it falls(because of the rigidbody) but the particle system emits where the sphere started out. I want it to emit where ever the sphere ends up. Because the sphere doesn't explode till 3 or so seconds.

 var explosionPrefab : Transform;
 
 function OnCollisionEnter(collision : Collision)
 {
     if (collision.gameObject.tag == "Hammer") 
     {
         audio.Play();    
         // Wait for the audio to have finished
         yield WaitForSeconds (audio.clip.length);
         Instantiate(explosionPrefab);
         Destroy(gameObject);
     }
 }
 @script RequireComponent(AudioSource)
Comment
Add comment · Show 1
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 AlucardJay · Feb 28, 2013 at 04:57 AM 0
Share

You have 3 questions now with ".... from a collision", what is it you don't understand.Please provide feedback to those who have answered you, or at least accept their answers for their effort.

The answer you are looking for is on this question of yours : http://answers.unity3d.com/questions/407838/how-to-create-particle-system-on-a-collision.html

2 Replies

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

Answer by LukaKotar · Feb 28, 2013 at 01:14 AM

You should google it or check the reference for Object.Instantiate.

Instantiate() uses three parameters. First is the object you want to instantiate, next is position and rotation. Separate them by commas.

Like that:

 Instantiate(explosionPrefab, transform.position, Quaternion.identity);


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
avatar image
0

Answer by elhispano · Dec 06, 2013 at 04:15 PM

I recommend you to use a single ParticleSystem for the same types of bullets and use ParticleSystem.Play() or Emit() (depending on the scenario) each time there is a collision. Using Instantiate and Destroy is going to generate a lot of work for the garbage collector so you can get performance problems.

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

12 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

How to Destroy a gameobject on collision 3 Answers

destroy child object 2 Answers

problem with shooting killing script 1 Answer

How to delay lines of code. 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