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 mcfetrmatt · May 09, 2012 at 11:21 PM · triggereventrain

Help to trigger a rain event

Hi there,

I am simply wanting to tell the rain particle system to start when I reach a certain point and stop when I leave that area. I am new to Unity 3D so it's been hard to make sense of posts i've searched for on this topic.

So far I have rain (snow) and a box with mesh render turned off. I was told this is how to start off but not sure how to continue. ANY help greatly 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 Shawn Miller · May 09, 2012 at 11:38 PM

You actually don't need a mesh renderer at all. If you create a Particle System, you can add a Box Collider component to it, set the size of the area you want it to rain in, and make sure IsTrigger is checked on the Box Collider. Once you have that you can attach the following script (this is in C#) and as long as your player has the Player tag, when they walk through it, the particle effect will trigger.

 public class ParticleTrigger : MonoBehaviour {

     // Use this for initialization
     void Start () {
         particleSystem.Stop();
     }
 
     void OnTriggerEnter(Collider other) {
         if (other.tag == "Player") {
             particleSystem.Play();
         }
     }
     
     void OnTriggerExit(Collider other) {
         if (other.tag == "Player") {
             particleSystem.Stop ();
         }
     }
 }
Comment
Add comment · Show 9 · 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 mcfetrmatt · May 13, 2012 at 12:11 AM 0
Share

Hey $$anonymous$$, thanks again for the reply but I am only more confused now. How I tried to deal with this code doesn't seem to work. I am using version 3.4.0f5 of unity. I posted back the other day with an image but it doesn't seem to be here and this forum layout is very hard to work. Says you have posted 3 answers but I can only see 2??

Do I need to replace parts in this code with tags I have in the project?

$$anonymous$$atthew

avatar image syclamoth · May 13, 2012 at 12:15 AM 0
Share

This code is in C#- make sure you're not trying to put it in a UnityScript file. As for the layout, just remember that this isn't a forum- it's not really designed for long-winded, linear discussions. There's a question at the top, and a bunch of individual answers which should theoretically be sorted by an active and caring community to show you the most correct one. Unfortunately, it doesn't really seem to work like that, because there are only about 50 people who ever come here more than once and have the ability to vote on things.

avatar image mcfetrmatt · May 13, 2012 at 12:57 AM 0
Share

Great thanks! So C# ae.. When I straight copy and past the above script into a C# script I get this error:

"Assets/Scripts/Rain_C.cs(1,32): error CS0246: The type or namespace name `$$anonymous$$onoBehaviour' could not be found. Are you missing a using directive or an assembly reference?"

Any ideas why? Do I attach this script to the particle system or the first person controller?

$$anonymous$$atthew

avatar image syclamoth · May 13, 2012 at 01:00 AM 0
Share

Well, it's because you're also overwriting the bit where it tells the compiler where to look for all that information! The lines

 using System;
 using UnityEngine;

are very important. Without that second one, it won't know what a $$anonymous$$onoBehaviour even is!

Add the script to the particle effect. $$anonymous$$ake sure the particle effect also has a box collider, set to trigger.

avatar image mcfetrmatt · May 13, 2012 at 01:09 AM 0
Share

Thanks syclamoth! You're a REAL help. I'm now getting this error:

"Assets/Scripts/Rain_C.cs(8,8): error CS0103: The name particleSystem' does not exist in the current context" When I change particleSystem' to the name tag for the particle system the same error pops up with the tag name ins$$anonymous$$d??

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Trigger Event, Ring Pass thru Rod Object 3 Answers

create event on collision 2 Answers

How would I detect a right click with an event trigger? 3 Answers

Animation playing other object animation 0 Answers

How to use the deselect Event Trigger? 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