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 Lboy · May 21, 2012 at 02:28 AM · rigidbodycollidertriggerparticlesemitter

how to turn a particle emitter on & off with a rigidbody trigger?

Hi there,

I'm attempting to turn a waterfall on & off when the rock mesh is placed on top of it. When the rock is present, the emitter should be off, when the rock is not, the emitter should be on.

I have an invisible plane collider with the waterfall particle emitter attached as a child, I then have a rock-mesh with a rigidbody & collider attached to it, is trigger is also ticked on the rock.

I know I need to tag the rock, then tell the invisible plain "if the collision is true, turn off the emitter, if false turn on the emitter." but I'm not so sure how to go about doing this as i'm pretty new to coding.

If anybody could shed some light on this I would really appreciate this.

Thanks.

alt text

waterfall collider.jpg (157.8 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
0

Answer by Lo0NuhtiK · May 21, 2012 at 02:54 AM

Something like this on the waterfall collider object (in C#):

 public ParticleEmitter myEmitter ; //then drag/drop the emitter on here in inspector
 /** or if you don't want drag/drop it -->**/ ParticleEmitter myEmitter ;
 /** if myEmitter isn't public drag/drop -->
 void Start(){
    myEmitter = GetComponentInChildren<ParticleEmitter>() as ParticleEmitter ;
 } <--**/
 
 void OnTriggerEnter(Collider other){
    if(other.CompareTag("Rock"))
       myEmitter.emit = false ;
 }
 
 void OnTriggerExit(Collider other){
    if(other.CompareTag("Rock"))
       myEmitter.emit = true ;
 }



Or if you want it on the rock... (in UnityScript):

 var waterfall : ParticleEmitter ; //drag the waterfall emitter object on here

 function OnTriggerEnter(other : Collider){
    if(other.CompareTag("WatefallTriggerPlaneThing"))
       waterfall.emit = false ;
 }

 function OnTriggerExit(other : Collider){
    if(other.CompareTag("WaterfallTriggerPlaneThing"))
       waterfall.emit = true ;
 }


...somethin like that. All untested and I'm half-asleep again, but think I got it right (or at least close enough for you to get it figured out).

Comment
Add comment · Show 2 · 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 Lboy · May 21, 2012 at 11:45 PM 0
Share

Hey man, i tried both methods and neither worked. I keep getting this error...

 Assets/Waterfalltrigger.cs(8,6): error CS0116: A namespace can only contain types and namespace declarations

I kinda need the script attached to the waterfall plane so I havent tried your other method, what exactly am i doing wrong?

thanks

avatar image Lboy · May 22, 2012 at 12:20 AM 0
Share

Ok I've fixed that problem, but my Rock (Trigger) keeps falling through the floor, This is because the Is Trigger is ticked, when i remove the tick it doesnt fall through the floor but obviously this removes the trigger. Any idea how I can get around this?

Thanks

avatar image
0

Answer by Lboy · May 22, 2012 at 12:32 AM

Actualy I've fixed that but the problem now is the Rock (Trigger) keeps falling through the floor, this is because is Trigger is ticked, when i remove the tick it doesnt fall through the floor but this obviously removes the trigger needed to turn on the emitter.

Any idea how I can go about fixing this?

Thanks.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How to get collision point when using onTriggerEnter 5 Answers

Moving kinematic rigidbody trigger against kinematic rigidbody collider 0 Answers

Colliding with Terrain and Destroying it 1 Answer

OnTriggerEnter/Exit called unexpectedly 2 Answers

OnTriggerEnter fails to activate 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