Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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
1
Question by andracer108 · Feb 19, 2017 at 10:48 PM · c#3dcollision detectionparticlesystemparticle collision

How to make particles collide with something but at the same time phase through it

Description

I am currently making a Unity game where I have an entity which fires a laser blast and I am currently using a Particle System. However, every time I try to mess around in the Collision settings, I can't seem to find a way on how to make the Particles detect a collision on a specific gameobject but at the same time, allow the particles to travel through it.

Details

I am using OnParticleCollision() to detect when the particles are actually hitting the object with this code:

 void OnParticleCollision(GameObject other)
     {
         if (other.name == "name")
         {
             Debug.Log("Working!");
         }
     }

The actual script is also attached to the gameobject which produces the Particle System. Like I said before, when I tamper with the Collision settings, the only time I get it to detect the collision and show the "Working!" log message is when the particles actually bump into the object whereas I want the actual collision to be detected but at the same time, the particles phase through.

If these are not enough details, I will gladly add more. All you have to do is ask. :)

P.S. I also searched all over the web to try and find something but no luck... and sorry if this is a newbie question or I did something wrong. I am a bit new here.

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
5
Best Answer

Answer by andracer108 · Feb 26, 2017 at 01:22 PM

It seems I have answered my own question. Instead of using the Collision module, the actual behaviour I'm seeking could only be provided by the Triggers module in the Particle System component.

What I did was, I enabled the Triggers module, specified the Collider and set the Enter value to Callback which enters the function OnParticleTrigger() when a particle encounters the Collider specified.

This is the code which made it fully functional:

     public ParticleSystem ps;
     List<ParticleSystem.Particle> enter = new List<ParticleSystem.Particle>();
 
     // Use this for initialization
     void Start () {
         ps = GetComponent<ParticleSystem>();
     }
 
     void OnParticleTrigger()
     {
         int numEnter = ps.GetTriggerParticles(ParticleSystemTriggerEventType.Enter, enter);
 
         for (int i = 0; i < numEnter; i++)
         {
             ParticleSystem.Particle p = enter[i];
             //take damage
             enter[i] = p;
         }
 
         ps.SetTriggerParticles(ParticleSystemTriggerEventType.Enter, enter);
 
         Debug.Log("Working!");
     }

Hope this helps whoever stumbles upon the problem I encountered! :)

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 vahn1231 · Jul 04, 2019 at 11:13 PM 0
Share

The question is how to get specified collision while your object span by instantiate.. Sorry newbie question

avatar image
0

Answer by denholmspurr · Apr 24, 2020 at 02:33 AM

I'm encountering a similar issue. I want my game object to recognise collisions/triggers of particles but I need "is trigger" to remain on for the rigid body of my Game object or it can't move correctly.

I've tried using the script above and attaching it to the Game object, removing line 6 and then adding the particle system in the scene editor.

Zilch, sadly. it's not registering. Any ideas? @andracer108

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 Sonmar · Jul 02, 2021 at 10:21 AM 0
Share

This script should be attached to the game object with a Particle System component, which uses Trigger module

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

7 People are following this question.

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

Related Questions

Need help with Collider detection with Physics.OverlapSphere() 0 Answers

How To Make Particles Play On Impact? 1 Answer

Particles colliders do not be detected by bullets with 'continuos dynamic' collision detection. 2 Answers

Unity 2D Particle System's collider doesn't trigger other colliders for scripts. 0 Answers

Collision problem 4 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