Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How to animate secondary maps?

Discussion in 'Scripting' started by ToboTheRibbler2, Apr 1, 2015.

  1. ToboTheRibbler2

    ToboTheRibbler2

    Joined:
    Apr 1, 2015
    Posts:
    1
    Hi there,

    I'm trying to animate water with the unity 5 standard shader.
    I have to normal maps assigned to the material. First as Main Map the second under "Secondary Maps".

    If I try to animate the offset of the texture with "_MainText" only the first Map ist moving.
    How can I animate the secondary normal map a assigned?
    With "_BumpMap" nothing happens.

    Here is my Script:

    Code (CSharp):
    1.     Renderer rend;
    2.     public float speed = 0.5f;
    3.     Vector2 start = Vector2.zero;
    4.     string normal = "_BumpMap";
    5.     string main = "_MainTex";
    6.  
    7.     // Use this for initialization
    8.     void Start () {
    9.  
    10.         rend = GetComponent<Renderer>();
    11.     }
    12.    
    13.     // Update is called once per frame
    14.     void Update () {
    15.         start += (new Vector2(speed, 0f) * Time.deltaTime);
    16.         if (rend.enabled)
    17.         {
    18.             rend.material.SetTextureOffset(main, start);
    19.         }
    20.     }
    Thanks for helping me out.
     
  2. joshuatg777

    joshuatg777

    Joined:
    Aug 15, 2020
    Posts:
    6
    For me, setting stuff to "_DetailAlbedoMap" seemed to work.

    Example:
    Code (CSharp):
    1. rend.material.SetTextureOffset("_DetailAlbedoMap", start);