• 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
Question by BHS · Feb 03, 2012 at 09:44 PM · collisiontexturetriggertagfade

Fade texture on collision/trigger with certain tag or layer?

We're developing a storm system and we have a two cylindrical layer systems that handle the rain and mist effects. We need them to fade on collision or trigger when entering a certain layer or tag (a house or inside area) then fade back in when out of the trigger area, but the collision can't interfere with the players motion. It has to just act as just a trigger.

Is there anyway to do this? If you guys could help us out that'd be great thanks.

Something like this which doesn't seem to work? And doesn't handle tags so we're not really sure how to go about this..

var glowColor : Color = Color.grey; private var dot : float = 0.5f;

function Update () {

if (collider.isTrigger == true) renderer.sharedMaterial.SetColor ("_TintColor", glowColor * dot); }

Comment

People who like this

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

Answer by aldonaletto · Feb 04, 2012 at 12:04 AM

I'm not sure if I understood exactly what you want to do. If you have rain and mist generators attached to the player, and want to fade them when the player enters some selected volumes, you can use something like this (player script):

var inTrigger: int = 0; // is > 0 when inside any "FadeArea" trigger var rain: GameObject; // rain generator var mist: GameObject; // mist generator

function OnTriggerEnter(other: Collider){ if (other.tag == "FadeArea"){ // if entering a FadeArea trigger... inTrigger++; // increment the inTrigger counter } }

function OnTriggerExit(other: Collider){ if (other.tag == "FadeArea"){ // if leaving a FadeArea trigger... inTrigger--; // decrement the inTrigger counter } }

function Update () { var fade: float = 1.0; // fade factor: is 1.0 for normal color... if (inTrigger > 0) fade = dot; // and "dot" when faded rain.renderer.sharedMaterial.SetColor ("_TintColor", glowColor fade); mist.renderer.sharedMaterial.SetColor ("_TintColor", glowColor fade); } This script will fade the color whenever the player enters a trigger tagged "FadeArea". A counter is used to handle overlapping triggers: inTrigger is zero only when the object is outside all "FadeArea" triggers.

Comment
swisscoder

People who like this

1 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 BHS · Feb 04, 2012 at 07:48 AM 0
Share

Thank you very much for this it helps a lot. Can't really get it working but we'll try to figure it out. It keeps saying there is no collider on mistsystem when there is. Do I deactivate the collision, leave the trigger on or off? How do I make the make player be able to walk threw trigger zones?

Thanks again!

avatar image aldonaletto · Feb 04, 2012 at 09:08 AM 0
Share

To cause a OnTrigger event, at least one of them (the moving object or the trigger) must be a rigidbody or CharacterControler - the collider alone isn't enough. At least in trigger->character collisions, a kinematic rigidbody attached to the trigger works fine.

avatar image

Answer by Berenger · Feb 03, 2012 at 11:48 PM

I believe you are looking for this : http://unity3d.com/support/documentation/ScriptReference/Collider.OnTriggerEnter.html

Comment

People who like this

0 Show 0 · 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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

6 People are following this question.

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

Related Questions

Tag Player in VRTK 1 Answer

OnTriggerEnter2D is not working 1 Answer

Checking trigger collision on other objects? 2 Answers

Putting an object somewhere to destroy something else 1 Answer

On Click, destroy object and any colliding object with the same tag. 6 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