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 thestrandedmoose · Jan 13, 2018 at 09:53 PM · triggerparticlesystem

Put out fire with water particleSystem

Hey all- I have a question about using particles to trigger some code much like OnTriggerEnter. Basically I have a particlesystem of water streaming. When a water particle from that system collides with my trigger, I want the fire in my scene to stop. Does anyone know how to achieve this? Seems to be very few or no tutorials on the subject and Unity's documentation for OnParticleTrigger is not really clear to me as a beginner coder

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 KittenSnipes · Jan 15, 2018 at 06:13 AM

@thestrandedmoose

So this is a script that you would attach to your particle system that streams water:

 public ParticleSystem part;
     public List<ParticleCollisionEvent> collisionEvents;
 
     void Start()
     {
         part = GetComponent<ParticleSystem>();
         collisionEvents = new List<ParticleCollisionEvent>();
     }
 
     void OnParticleCollision(GameObject other)
     {
         int numCollisionEvents = part.GetCollisionEvents(other, collisionEvents);
         int i = 0;
 
         while (i < numCollisionEvents)
         {
             if (other.tag == "Fire")
             {
                 other.SetActive(false);
             }
             i++;
         }
     }

You need to make sure to set the triggers module on the ParticleSystem to on and also turn on the collision module. You need to do that to the water particle system. For the fire particle system you need to turn on the collision module. For each collision module you also need to enable the little checkbox under the collision module which is labeled 'Send Collision Messages'. Also make sure to set the type of the collision module to world. Ill add a video so you can see everything.

Heres that video:

The Tutorial Video

Comment
Add comment · Show 3 · 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 KittenSnipes · Jan 15, 2018 at 06:14 AM 0
Share

@thestrandedmoose

If you have any more questions feel free to comment on my answer :D.

avatar image thestrandedmoose · Jan 15, 2018 at 08:25 PM 0
Share

Wow really awesome explanation! Thank you!

I was also wondering- let say my object with the fire is prefab- like a burning crate or tree. I've already set up fire particle systems around the tree to play on certain events. like so:

 //This script is on my tree prefab
 void OnTriggerStay (Collider other)
     {
         if (other.tag == "Player" && (PlayerCanlightThingsOnFire)) {
              {
                 fire1.Play ();
                 fire2.Play ();
                 smoke.Play ();
                                 TreeOnFire = true;
                         }
            }

I've set the Prefab up to stop the fire when TreeOnFire = false., and to destroy the tree if TreeOnFire == true for 10 seconds.

So I'm wondering if there's a way to set TreeOnFire to false when water particles collide with it (or enter the TriggerBox surrounding the tree). This way the fire will turn off, the TreeOnFireTimer will reset, and all will be well with the world lol

I'm wondering how you would achieve this, and will it work for all prefabs in the scene?

avatar image aksualeyna96 · Jan 16, 2021 at 05:41 PM 0
Share

I did exactly the same but it doesn't work. Please can you help me?

avatar image
1

Answer by getyour411 · Jan 14, 2018 at 06:21 AM

This looks promising:

https://unity3d.com/learn/tutorials/topics/scripting/particle-collisions

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

92 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 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 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 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

Particles Colliding with Triggers 1 Answer

ParticleSystem Call 1 Answer

linking particlesystem to cube,conecting particlesystem to cube 0 Answers

ParticleSystem TriggerModule: Collide with world / collide with unlimited colliders? 0 Answers

Make particle system cover a part of the parent, depending on the the part of the object that is colliding 0 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