• 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 FreeTimeDev · May 08, 2011 at 01:41 PM · alphaanimated-texture

Renderer Alpha Cutoff

I'm aware of the post by Erich here, but I'm having difficulties implementing this.

I have two planes. One is a "GUI" element and the other will serve as a cool down timer of sorts. This timer is intended to display the cool down left on the ability, like an a MMO. Currently, the code, I think, sets the alpha cutoff and that's it. Naturally, this wouldn't work as intended if it wasn't animated!

Here's what I have:

var maxTime : float = 1.0; var canShoot : boolean = true; var rate : float = 0.0; var animate : boolean = true;

function Start() { maxTime = RClick.reloadTime; renderer.enabled = false; }

function Update () { rate -=Mathf.InverseLerp(1, 0, Mathf.SmoothStep(1, 0, Time.deltaTime * maxTime));

 if (animate == true)
 {
 renderer.material.SetFloat("_Cutoff", rate);
 }

         if(Input.GetButtonDown( "Fire1" ) && PauseMenu.isPaused == false && canShoot == true)
             {
                 canShoot = false;
                 renderer.enabled = true;
                 //renderer.material.SetFloat("_Cutoff", Mathf.InverseLerp(0, 1, (Time.deltaTime / maxTime)));
                 animate = true;
                 Reset();
             }
 }

function Reset() { yield WaitForSeconds (maxTime); renderer.enabled = false; maxTime = RClick.reloadTime; canShoot = true; animate = false; }

Edit: The question is how to fix it so that it animates smoothly over the correct duration (maxTime, ~3 seconds). I've since updated my code to show what I've changed. I've got it animating right now, but it's not for the full duration (0-1 over 3 seconds). It seems like its starting at 0 and going to .3, then starting at .3 then going to .6 etc.

Comment
Add comment · Show 2
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 Jessy · May 08, 2011 at 11:57 PM 0
Share

I don't see a question. Regardless, it's not going to work right; color channels are 0-1, not 0-100.

avatar image FreeTimeDev · May 09, 2011 at 12:44 AM 0
Share

I've updated my question.

0 Replies

· Add your reply
  • Sort: 

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

No one has followed this question yet.

Related Questions

Convert to .tiff, with fbx export, removes the alpha channel? 1 Answer

GUI.DrawTexture - Slightly Transparent? 1 Answer

Performance drop with transparent objecs overlying big meshes 1 Answer

AlphaSelfIllum shader can see through textrues 1 Answer

Define the alpha on a GUI material component (in editor) 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