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 OVillanueva · Jan 15, 2015 at 11:18 PM · collisioncolliderparticles

Activating Particle Effect on Collision:

So I have a Particle Effect prefab attached to an object - object contains a Rigid Body and Box Collider. This Particle Effect should play once when it comes in contact with another object with a Collider. I've set the Collider on the object as: "Is Trigger".

This is the script I've been working on. I'm obviously missing components but hopefully moving in the right direction:

using UnityEngine;

using System.Collections;

     public class ParticleStarter : MonoBehaviour{


 void OnCollisionEnter (Collision col)

 {
     if(col.gameObject.other (ParticleEmitter)

     
        ParticleEmitter.enabled = (true);


        }

}

Any help would be appreciated.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by DanSuperGP · Jan 15, 2015 at 11:33 PM

You need to have a reference to your specific particle system. If the script is on the same game object, the easy way to do it is this. You can also make _psystem public and drag the particle system reference onto it.

 [RequireComponent(typeOf(ParticleSystem))]
         
 public class ParticleStarter : MonoBehaviour{
             
      private ParticleSystem _psystem;
         
       void Awake() {
           _psystem = GetComponent<ParticleSystem>()
        }
         
        void OnTriggerEnter (Collider col)  {
 
   
                  _psystem.Play();
       
         }
         
  }











Comment
Add comment · Show 7 · 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 OVillanueva · Jan 15, 2015 at 11:43 PM 0
Share

I'll give this a try. Thank you.

avatar image OVillanueva · Jan 16, 2015 at 12:37 AM 0
Share

Right now, the particle effect shows a default setup that's already in the Active state once the Object appears.

I changed the "private ParticleSystem_psystem" to "public ParticleSystem_psystem;"

Afterwards, I assigned my particle system within the Inspector when the option became visible.

Right now, my specified particle effect does not appear. Also, the default particle effect turns on right away, regardless whether there was a collision detected or not.

Did I miss something?

avatar image DanSuperGP · Jan 16, 2015 at 12:45 AM 0
Share

Well... if you're going to make it public. you should delete the RequireComponent and GetComponent lines.

Also, you should turn off playonawake on the particle system you want to trigger.

avatar image DanSuperGP · Jan 16, 2015 at 12:48 AM 0
Share

If the script isn't on the same object as the particle system you are trying to activate, it's probably creating a new default particle system... and then overriding your publicly assigned particle system.

avatar image OVillanueva · Jan 16, 2015 at 01:28 AM 0
Share

I think there is a issue happening when I have the collision effect and spawn effect happening at the same time. At one point, it was working, then it suddenly stopped after a few collisions.

Show more comments

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

26 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

Related Questions

World particles collider scriptable? 1 Answer

Projectile Collision help 2 Answers

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

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

Keep particles to defined area, destroy on collision 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