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 /
  • Help Room /
avatar image
0
Question by $$anonymous$$ · Jan 05, 2016 at 03:20 PM · particle systemplay

Idiot can't play a particle system onCollisionEnter

MAN I hate posting questions for which the answers are trivial, but I'm getting frustrated here. Here's me code:

 public class HeroScript : MonoBehaviour
 {
     ParticleSystem myPartSys;
 
 
     // Use this for initialization
     void Start ()
     {
         myPartSys = GetComponent <ParticleSystem> ();
     }
     
     // Update is called once per frame
     void Update ()
     {
     
     }
 
     void OnCollisionEnter2D (Collision2D other)
     {
         myPartSys.enableEmission = true;
         myPartSys.Play();
     }
 
 }

Comment
Add comment · Show 7
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 $$anonymous$$ · Jan 04, 2016 at 10:35 PM 0
Share

OOPS I left out

using UnityEngine; using System.Collections;

public class HeroScript : $$anonymous$$onoBehaviour { ParticleSystem myPartSys;

avatar image gjf $$anonymous$$ · Jan 04, 2016 at 10:40 PM 1
Share

i fixed your formatting. any errors?

avatar image $$anonymous$$ · Jan 05, 2016 at 12:01 AM 0
Share

No errors, but it still won't play the particle system when I collide the other game object with the object the script is assigned to...

avatar image gjf $$anonymous$$ · Jan 05, 2016 at 01:53 PM 1
Share

it's definitely getting to OnCollisionEnter2D()?

avatar image $$anonymous$$ gjf · Jan 05, 2016 at 02:04 PM 0
Share

Yeah, I'm sitting here repeatedly bringing the 2 objects together manually while in Play mode double and triple checking the collision. I'm having trouble in general with the ParticleSystem.Play methodology, whether to use myParSys.emission.enabled or myParSys.Play or myParSys.emission.enabled = true or myParSys.enableEmission = true or whatever the syntax should be... the online suggestions seem to vary between these

Show more comments

2 Replies

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

Answer by skillbow · Jan 05, 2016 at 04:14 PM

@bobmaxine This might be worth a try

 ParticleSystem.EmissionModule myPartSys;

 void Start ()  {
     myPartSys = GetComponent<ParticleSystem>().emission;
 }

 void void OnCollisionEnter2D (Collision2D other)  {
     ParticleSystem.EmissionModule em  = myPartSys;
     em.enabled = true;
 }
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
avatar image
0

Answer by $$anonymous$$ · Jan 05, 2016 at 07:57 PM

Yeah sorry, I responded earlier but I guess it's not up yet... turns out I got it going with my above code (didn't need the "myPartSys.enableEmission = true;"), but had not realized I needed a rigidbody 2D specifically on the object with the above code.

I hate having such a simple question not only frustrate me but have you kind people spend your valuable time on. Thank you.

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 skillbow · Jan 05, 2016 at 10:33 PM 1
Share

I was pulling my hair out on a similar one just the other day. Glad you got it sorted.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

[Solved]How do I get a cannonball splash effect? 1 Answer

Are there global particle settings? / My size doesn't fit tutorial size. 0 Answers

Unity 2018 Particle system sub emitter has a problem.,Unity2018.2 Particle system Sub-emitter has a problom. 0 Answers

Don't want particles emmitting perpendicular to donut shape 1 Answer

Help with pour effect script not registering in SteamVR? 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