• 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 hanso · Jun 14, 2012 at 05:48 PM · image effectsglow

turn image effect on/off at a specific area

hey everyone. so, here's my problem: If got an character moving with fps Controller from the unity standard assets on a straight plane. area a -to- b should have the pro image effect "glow", area b -to- c should be without it.

a=========b====c I with effect I I not I

the ground has a self illumine material, and the glow effect is attached to the main camera of the fps view. I'm a beginner at scripting, how can i turn the effect now on/off?

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

Answer by hijinxbassist · Jun 14, 2012 at 06:44 PM

You would get that component on the main camera and set enabled to false.

 Camera.main.GetComponent(GlowEffect).enabled=false;
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 hijinxbassist · Jun 15, 2012 at 12:43 AM 0
Share

@hanso So when you hit point 'b'(however you deter$$anonymous$$e that event, by trigger or what-have-you) just say that line to turn the effect off. If you want to turn it on again, set enabled back to true (enabled refers to the check box next to the script name in the inspector). Heres an example with trigger:

 //Trigger for the B-C section
 
 function OnTriggerEnter(other:Collider)
 {
     if(other.name=="Player") //Player entered the trigger
         Camera.main.GetComponent(GlowEffect).enabled=false;
 }
avatar image hijinxbassist · Jun 15, 2012 at 12:45 AM 0
Share

Can you put your comment in the comment section ins$$anonymous$$d of the answer box, helps ppl sift through the answers better. You can just delete it at this point tho, since i read it :)

avatar image hanso · Jun 15, 2012 at 07:16 AM 0
Share

hey! thank you again! so, this is how i made it now: at the point B, I set up an box collider and put your script in it. It's working now - when my player01 touches it, the effect is turned off.

But, i get this warning in the console:

Destroying object immediately is not permitted during physics trigger and contact callbacks. You must use Destroy ins$$anonymous$$d. UnityEngine.Object:DestroyImmediate(Object) GlowEffect:OnDisable() (at Assets/Standard Assets/Image Effects (Pro Only)/GlowEffect.cs:69) UnityEngine.Behaviour:set_enabled(Boolean) triggerding:OnTriggerEnter(Collider) (at Assets/triggercameffect.js:6)

2nd. If it's not a huge hardcore code, is it possible to turn it off a little more "gently". like the 3dsound, if my player walks through the trigger, the effect turns off slowly

avatar image hijinxbassist · Jun 15, 2012 at 08:45 AM 0
Share

Hmm...you know i did not test it, but lerping one(or all) of the values to ease the effect out will be better anyway. For the "gentle fade" you will need to Lerp some of the values down to 0. This is quite a bit different from the original question now, so i suggest doing a search for previous questions about Lerp. Heres a good example of http://answers.unity3d.com/questions/14288/can-someone-explain-how-using-timedeltatime-as-t-i.html>lerp, you will change the functions parameters to floats and ins$$anonymous$$d of Vector3 you will use $$anonymous$$athf.

The basic idea is to gradually decrease a variable(float) over the course of a specified time(t). In this case the vars are glowIntensity, blurIterations, and blurSpeed. It takes some time to get use to using Lerp(or Slerp for longer fades), but once you get the hang of it youll be lerping all over the place :) As for the enabled portion,do away with it completely. Also store the starting values in some vars, that way if you want to lerp the effect back in you will have those values handy.

avatar image hijinxbassist · Jun 19, 2012 at 07:21 AM 0
Share

@hanso Heres a link to a post i just did for this same effect. http://answers.unity3d.com/questions/269791/delta-component.html>Fade in float values using $$anonymous$$athf.Lerp.

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.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Image Effects Causing Bright Glow on Startup 0 Answers

Add glow effect around UI Layout 2 Answers

Neon light or LED light 1 Answer

Why is Alpha Cutoff Shader affected by glow? 2 Answers

Glow single Object 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