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 kilian277 · Apr 12, 2012 at 07:03 PM · particlesemitterleaves

Activating a particle emitter whith onTriggerEnter ?

Hi,

If i just made a box collider in an area in my game (that is a forest) and when the player enters the collider , how to activate the leaves particle emitter ?

I have a leaf particle emiteer and i have this script but it isn't working

============

var particles : GameObject; function OnTriggerEnter(other : Collider){

 if(other.gameObject.CompareTag("player")){
 
     particles.emit = true;
 }

}

================

I prefer to script in Javascript.

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

5 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by TurboHermit · Apr 12, 2012 at 08:35 PM

Should look something like this.

var PartEmit : ParticleEmitter; function OnTriggerEnter (other : Collider) { PartEmit.particleEmitter.emit = true; }

Haven't tested it though.

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 kilian277 · Apr 13, 2012 at 10:58 AM 0
Share

should i put the script on the collider or the particle emitter ?

avatar image TurboHermit · Apr 13, 2012 at 11:41 AM 0
Share

The collider

avatar image
0

Answer by GC1983 · Apr 12, 2012 at 08:21 PM

If you haven't done so, try making the P in particle lowercase; particleEmitter.

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 kilian277 · Apr 12, 2012 at 08:35 PM 0
Share

no it's good that way , monodevelop highlights it in blue and when setting the p in lowercase unity doesn't find it.

avatar image
0

Answer by john-essy · Apr 12, 2012 at 11:06 PM

 var particles : GameObject
 
 if(other.gameObject.tag == ("player"))
 {
     particles.enabled = true;
 }
 else 
 {
     particles.enabled = false;
 }
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 TurboHermit · Apr 13, 2012 at 11:47 AM

I believe the tag is Player, not player.

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 kilian277 · Apr 13, 2012 at 01:44 PM 0
Share

i already changed that bu thanlks

avatar image
0

Answer by TheFrankman123 · Apr 13, 2012 at 11:51 AM

try 'FindWithTag' instead.

and your variable should be 'var particles : ParticleEmitter;' so it's as follows:

 var particles : ParticleEmitter;
 
 function OnTriggerEnter (other : Collider) {
 
      if(other.gameObject.FindWithTag("player")) {
 
           particles.emit = true;
 
      } else {

          particles.emit = false;
      }
 
 }




Make sure you accept the answers that helped you.

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 TheFrankman123 · Apr 13, 2012 at 11:52 AM 0
Share

Also unless you have written your own tag the the tag will be "Player" with a capital P.

avatar image kilian277 · Apr 13, 2012 at 01:32 PM 0
Share

thanks for the answer i will see if this works. About the capital P in the script it is player , but i changed it in the script already to a P.

avatar image kilian277 · Apr 13, 2012 at 01:48 PM 0
Share

still no luck.

i'm going to look for other questions with the same thing.

But everyone thanks for the help !

avatar image TheFrankman123 · Apr 13, 2012 at 03:17 PM 0
Share

This answer IS correct. Have you made the particle emitter a child of the object the script is attached to? and have you dragged the particle emitter onto the public variable in the inspector?

avatar image kilian277 · Apr 13, 2012 at 03:35 PM 0
Share

The emitter is a child of a character controller so it follows the character, and it is assigned at the script variable in the inspector,the thing is when this character hit the box collider that surrounds the forest it needs to start emiting some leafs at the position of the character so it is a child of it.

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

9 People are following this question.

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

Related Questions

How to make windswept snow on mountains? 0 Answers

How to pause emitter in new Particle System? 2 Answers

Modifying particle renderer material and assigning new particle emmitter 1 Answer

Accessing Particle emitter 0 Answers

ARK of the COVENANT | How do I trigger Particles to come out once the top has been removed? 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