Search Unity

Speaking of animated bumps

Discussion in 'Scripting' started by azabug, Aug 30, 2007.

  1. azabug

    azabug

    Joined:
    Aug 8, 2007
    Posts:
    111
    I want to set a decreasing transparency level and I was thinking it might be more fun and more functional to do it with code ... (as the transparency levels could be tweaked without having to go back and forth between programs)
    What I'm curious about is setting the transparency levels of a texture map with code ... had a quick look through the manual but couldn't find a reference ... do you think it's possible .. or should I stick with importing multiple images with diminishing transparency?
     
  2. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
  3. azabug

    azabug

    Joined:
    Aug 8, 2007
    Posts:
    111
    I ended up using a few materials .. cause I was using a parallaxBump/AlphaDiffuse material and I didn't know how to apply the color.a to it ... here's the code ...
    Code (csharp):
    1.  
    2. var m1 : Material;
    3. var m2 : Material;
    4. var m3 : Material;
    5. var m4 : Material;
    6. var m5 : Material;
    7. var c = 1;
    8.  
    9. function Update () {
    10.     transform.localScale.x += 0.05;
    11.     transform.localScale.z += 0.05;
    12.     c = (c + 1);
    13.     if (c < 60) {
    14.         renderer.sharedMaterial = m1;
    15.     }
    16.     if (c == 60) {
    17.         renderer.sharedMaterial = m2;
    18.     }
    19.     if (c == 70) {
    20.         renderer.sharedMaterial = m3;
    21.     }
    22.     if (c == 80) {
    23.         renderer.sharedMaterial = m4;
    24.     }
    25.     if (c == 90) {
    26.         renderer.sharedMaterial = m5;
    27.     }
    28.     if (c == 100) {
    29.     Destroy(gameObject);
    30.     }
    31. }
    It's a bit clunky though ... basically the materials have different opacities set to them starting at 5, 4, 3 ,2 ,1 Destroy!! ... I'll keep playing around with it ... see if I can get my head around the method you suggested ... cheers for now!
     
  4. drJones

    drJones

    Joined:
    Oct 19, 2005
    Posts:
    1,351
  5. azabug

    azabug

    Joined:
    Aug 8, 2007
    Posts:
    111
    I'll definitely have a look at it tomorrow ... in the light of day ... it looks like it's the path to take ... thanks