Search Unity

Fade in and out 3D-Gameobject?

Discussion in 'Community Learning & Teaching' started by McPeppergames, May 29, 2023.

  1. McPeppergames

    McPeppergames

    Joined:
    Feb 15, 2019
    Posts:
    103
    I have tried to smoothly fade in a 3D-gamobject by changing it's materials alpha value (via script) over time but it does not seem to work correctly. I tried to manually move the slider which is working fine, but changing the value via script is somehow showing different "results" in the objects surface.
    It also seem to plop in with a much higher alpha value and is visible instantly and not smoothly. When I pause the game view and then move the slider it jumps back to transparent correct values.
    The renderer of the material is set to fade and I did try all the other settings... but somehow this is not giving the correct look.

    What am I missing here to smoothly fade in and out a 3D-gameobject? Is this even the "correct" way to do it or should I use a shader or something else?

    Any help welcome.
     
  2. makaka-org

    makaka-org

    Joined:
    Dec 1, 2013
    Posts:
    1,023
    Without your code, it's hard to suggest anything.

    I short, I got a nice result with not a linear changing of value using AnimationCurve class
    and my custom Material Control script. I also use additional texture to fade, a not just an alpha channel — to get a more interesting result.

    So, here in Basketball and AR Basketball examples,
    I use it for balls and for all elements of the basketball hoop.