Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 /
  • Help Room /
avatar image
0
Question by AlexDetermination · Apr 25 at 12:35 AM · materialbug-perhapsmaterial color

Fading not working out as intended

I wanted an object to fade out, but instead of fading, it kind of deep fries itself, like this:

alt text



As you can see, it actually does allow light to pass through and see objects behind, but it doesn't necessarily fade. At first, I thought it was a problem where one of the scripts in the star makes the star go rainbowy colored, and it intefered with the fade script in the main script, but when I merged them together, it still has a problem. When debugging, I turned off the color changing script, and made it so then the Alpha of the color is set to 50, but it still turns itself white. Any ideas what went wrong?

Code:

     // Update is called once per frame
     void Update()
     {
         // When the star reaches it's predefined y value, it will explode
         if (transform.position.y < 5) {
             Explode();
             hasExploded = true;
             StartCoroutine(DestroySelf());
         }
 
         // Runs the following code if it has exploded
         if (hasExploded) {
             // Gets the current color to keep the color while it's fading.
             Color objColor = GetComponent<Renderer>().material.color;
             
             // Set the fade amount to increase as time goes on
             float fadeAmount = objColor.a + (fadeSpeed * Time.deltaTime);
 
             // Sets the alpha argument to the fade amount
             material.color = new Color(material.color.r, material.color.g, material.color.b, fadeAmount);
             
             // Scale the star up by the scale speed
             transform.localScale += new Vector3(scaleSpeed, scaleSpeed, scaleSpeed) * Time.deltaTime;
         }
 
         // Gets the current color and converts it to HSV
         Color.RGBToHSV(material.color, out hue, out saturation, out brightness);
 
         // Sets the saturation and brightness
         saturation = 0.5f;
         brightness = 1.0f;
 
         // If it hasn't exploded, make it go rainbowy
         if (delay <= 0.0f && !hasExploded) {   
             hue += rainbowSpeed;
             material.color = Color.HSVToRGB(hue, saturation, brightness);
             
             delay = resetTime;
         }
 
         delay -= Time.deltaTime;
 
         // If the hue is at it's maximum, reset it
         if (hue >= 1) {
             hue = 0.0f;
         }
     }

prototype-4-prototype-4-pc-mac-linux-standalone-un.png (386.5 kB)
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

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

196 People are following this question.

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

Related Questions

How do i remove colored circles on materials? 0 Answers

Material darker in inspector then scene? 0 Answers

Every object I drag into the scene turns yellow 0 Answers

Changing a material's colors anywhere else besides the Update function has no effect,Changing Material's color works on Update but not on another method 0 Answers

All my models are white 2 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