Search Unity

Changing sprite with animator attached

Discussion in '2D' started by MatthieuP, Feb 3, 2015.

  1. MatthieuP

    MatthieuP

    Joined:
    Oct 23, 2014
    Posts:
    3
    Hello,

    I am trying to change a sprite of a gameObject at runtime using script or event with the Unity editor but it has no effect. Indeed an animator is attached to this gameObject and animation is played at some time. This animation modify the sprite when launched. However, no animation are launched when I am trying to update the sprite (Idle with no animation) but still no luck.

    Thank you.

    Matthieu
     

    Attached Files:

  2. grosssmutttr

    grosssmutttr

    Joined:
    Apr 15, 2014
    Posts:
    168
    You have to change the sprites in the animations. Then you define a trigger or bool in the animator and in the Script you call Animator.SetTrigger("yourTriggerName");

    Then the animation is changed and the new sprite should appear.