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 Renalon · Sep 04, 2018 at 04:20 PM · collisionparticlesboxcollider2d

Collision of particles with the box collider 2d does not work if the box collider 2d with the trigger checkbox marked

     void OnParticleCollision(GameObject other)
     {
         if (other.tag == "Enemy")
         {
             Debug.Log("Text");
         }
     }

alt text alt text

image1.jpg (53.9 kB)
image2.jpg (112.1 kB)
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

Answer by Chetzy · Sep 04, 2018 at 05:19 PM

The answer is simple, one collider that is trigger never get collisions or physics its only for events, you need to unselect the trigger option and the particle system is going to collision with the collider

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 Renalon · Sep 05, 2018 at 03:55 AM 0
Share

Thanks, I thought the collisions had to work.

avatar image
0

Answer by celinedrules · Aug 31, 2020 at 01:11 AM

know this is a little old but I did figure out a really simple way to do this.

In Unity on the particle system just make sure the Triggers section is checked and attach this script to the same GameObject

 using UnityEngine;
 
 public class Test : MonoBehaviour
 {
     // The particle System
     private ParticleSystem sys;
     // Array of alive particles
     private ParticleSystem.Particle[] aliveParticles;
     // The 2d collider that we want to collide with
     // the particle system
     private BoxCollider2D boxCollider;
     
     // Called when any particle meets the condition
     // of the trigger section of the particle system
     private void OnParticleTrigger()
     {
         // Check to see what needs to be initialized
         InitializeIfNeeded();
         
         // Get the particles that are currently alive
         // and store them in the array
         sys.GetParticles(aliveParticles);
 
         // Loop through the particles in the array
         foreach (ParticleSystem.Particle particle in aliveParticles)
         {
             // Check for collision
             if (boxCollider.bounds.Intersects(new Bounds(particle.position, particle.GetCurrentSize3D(sys))))
             {
                 Debug.Log("Success");
             }
         }
     }
 
     // Initialize the variables only once
     private void InitializeIfNeeded()
     {
         // Get the 2d trigger collider from the GameObject
         // This can be done in several different ways, I chose
         // to add a tag and find it that way
         if (boxCollider == null)
             boxCollider = GameObject.FindGameObjectWithTag("HurtBox").GetComponent<BoxCollider2D>();
         
         // Get the particle system we want to collide with and
         // add the 2d trigger collider to it
         if (sys == null)
         {
             sys = GetComponent<ParticleSystem>();
             sys.trigger.SetCollider(0, boxCollider);
         }
         
         // Initialize the array that holds the alive particles
         if (aliveParticles == null)
             aliveParticles = new ParticleSystem.Particle [sys.main.maxParticles];
     }
 }
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

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

Particle Collision / Trigger not being reported to On_xx Event 1 Answer

OnParticleCollision Question (Image included) Particle Decal Hanging off Edge 1 Answer

2D box colliders not touching but are colliding, how to fix? 0 Answers

can we attach a collider for each particle emitted by a emitter 1 Answer

Whirlwind spell collision detection 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