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 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.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

UI Fading in flicker 5.5 1 Answer

"alphaHitTestMinimumThreshold" and "Sprite.Create" Issue 1 Answer

How to create this type of mask? 0 Answers

change the alpha of a gameobject with multiple childs 1 Answer

Trying to change the alpha on a particle system. 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