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 NEXNET_Systems · Jun 08, 2015 at 08:06 PM · c#triggerobjectaiparticles

Emit Particle upon Death

Good Afternoon fellow Devs,

I'm currently working on a Particle System in co-operation with the Ai that emit's a particle upon the enemy's death but just before the body is removed and re-spawned.

I've went ahead and looked for some tips online, however the issue am having here is that the references to gameobject.GetComponent in Unity 5 has changed and suggests I upgrade thus breaking the script.

Is there a better method to do this? Any tips or suggestions are extremely helpful.

My goal for this code is to perform the following functions in C#

  1. Player kills AI

  2. AI dies

  3. A particle emits around the AI upon death

  4. The particle stops

  5. AI's body is removed from the game

  6. Re spawns.

I've got all except number 3 and 4 working, this is where I am having some trouble.

Code:

 public class BloodBath : MonoBehaviour
     {
         //Name of Particle to emit
         ParticleEmitter pe;
 
         private bool isDead = false;
         public float respawnTime = 10.0f;
 
         void Start() {
             ParticleEmitter pe = gameObject.GetComponent<ParticleEmitter> ().particleEmitter;
     }
         
         
         void Update() {
             
             if (isDead)
             {
             
                 //Play Particle upon Death
                 pe.emit = true;
                 
                 respawnTime -= Time.deltaTime;
                 
                 if (respawnTime <= 0.0f)
                 {
                     RemoveBody();
                 }
             }
         }
         
         public void AIDead()
         {
             isDead = true;
         }
         
         void RemoveBody() {
             
             Destroy(gameObject);
         }
         
     }
     
 }




alt text

errorwindow.png (31.8 kB)
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 Shark-Boy · Jun 08, 2015 at 09:22 PM 0
Share

It is called ParticleSystem now. As of 4.3 and later I think.

2 Replies

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

Answer by Bioinformatizer · Jun 08, 2015 at 09:33 PM

A good way to do this is to create an empty GameObject, attach the particle emitter to it, and store it as a prefab in your assets folder.

If you make a 'public GameObject prefabPe' in your current script in place of the 'ParticleEmitter pe', you can then move the prefab from your assets folder onto this script in the unity window.

You call instantiate on that asset like 'pe = Instantiate(prefabPe, gameObject.transform.postition, gameObject.transform.rotation);'

Then call 'Destroy(prefabPe, timeToWait);' Simple Enough Huh? Good Luck!

Ps. you do not need that getComponent with this method, so that can all go.

Comment
Add comment · Show 1 · 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 NEXNET_Systems · Jun 08, 2015 at 11:35 PM 0
Share

Thank you, this worked however just for future reference it worked just by using Instantiate ins$$anonymous$$d of pe = Instantiate and position had a small typo. But thank you none the less.

avatar image
1

Answer by Stoyanow · Jun 08, 2015 at 09:27 PM

https://www.youtube.com/watch?v=vwUahWrY9Jg∈dex=5&list=PLiyfvmtjWC_Up8XNvM3OSqgbJoMQgHkVz

About the particles

https://www.youtube.com/watch?v=4vOyENoIyH4∈dex=11&list=PLiyfvmtjWC_Up8XNvM3OSqgbJoMQgHkVz

This might help you with the re-construction of the code.

Comment
Add comment · Show 1 · 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 NEXNET_Systems · Jun 08, 2015 at 11:35 PM 0
Share

Thank you, i found this video very useful and all systems are go!

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

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

Related Questions

Weeping Angel AI / OnTriggerStay Problems 1 Answer

Guides or Tutorials for a Very Basic Enemy AI? [Unity 5] 1 Answer

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Detecting inside an area without a collider 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