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 24, 2012 at 04:01 AM · triggerparticlesemitterpoint-light

how to turn on an emitter with another emitter?

Hi,

I currently have a plane (camp fire) that has a fire emitter attached to it, I then have a flame thrower attached to the player. how would I go about creating it so that the emitter on the plane turns on its emitter when the player fires his flame thrower toward the planes collider? in addition i would like the point light to also turn on and off with the emitter but my coding is very poor.

I have my plane with the following C# scipt attached to it, isTrigger & convex are both ticked on the planes collider and a point light has been added as the child of this. myEmitter has been assigned with the flame thrower (drag and dropped)

     public class firetrigger : MonoBehaviour {
     
 public ParticleEmitter myEmitter = null;
 
 void OnTriggerEnter(Collider other){ if(other.CompareTag("Player")) myEmitter.emit = true ; }
 
  }

my flamethrower also has a world particle collider attached with "send collision message" ticked and the tag "player" attached to him.

Thanks in advance, I dont know what I would do without this site.

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

Answer by hijinxbassist · May 25, 2012 at 12:31 AM

One thing with this, you say myEmitter=null and then later tell it to emit. If there is no emitter, how will it emit? You could pass the emitter, but no reason to if you set it in the inspector. So heres what weve got:

A variable for the emitter with the fire emitter assigned to it from the inspector and emit set to false.

A variable for the point light with the light assigned from the inspector, the point lights enabled var set to false.

When particles collide with the fire pit plane, make fire pit emitter emit and turn on the light.

    On FirePit:
 public class firetrigger : MonoBehaviour 
 {
     void OnParticleCollision(GameObject other)
     { 
         myEmitter.emit = true ;
         myPointLight.enabled=true;
     }
 }
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 25, 2012 at 01:08 AM 0
Share

$$anonymous$$y mistake, even though I was telling it that it is null, I assigned it through the inspector. I should have mentioned this before.

I added these two lines above what you wrote and assigned them through the inspector, the particle system works perfectly now.

public ParticleEmitter myEmitter = null; public Light myPointLight = null;

to turn the point light on when the flames are ignited I added...

myPointLight.intensity = 6 ; //on the 14th line

All works perfectly, thanks for your help.

avatar image hijinxbassist · May 25, 2012 at 01:17 AM 0
Share

@coolkid808 No prob, there is one more condition you can surround the inside of the collision code with,

 if(!myEmitter.emit)  //if emit is false run the code
 {
     //Working code
 }

This way it will only run the "Working code" once, either way works though.

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 turn a particle emitter on & off with a rigidbody trigger? 2 Answers

No particle emitter in hieararchy, but particles still appearing?? 2 Answers

ParticleSystem.Play() does not play particle. 10 Answers

Get all particles within trigger collider? 1 Answer

Matching collision normal for sub-emitter 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