Search Unity

Animation.Rewind(); Not Working

Discussion in 'Animation' started by Ensarr53, Sep 5, 2021.

  1. Ensarr53

    Ensarr53

    Joined:
    Apr 5, 2021
    Posts:
    1
    Hi,
    In UNITY, I want to make the size of the object bigger than its original size when the mouse is pointed on it and turn back to its original size when the mouse goes away from the object.

    Actually, there isn't a problem when the objects size is getting bigger but when it is turning to its original size I am coming across an error. The Rewind() isn't working and wouldnt run back the animation. Am I doing something wrong? Or is there a different way to do it? I would be happy if someone can help me with this promlem of mine...

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class Control : MonoBehaviour
    4. {
    5.     public Animation anim;
    6.  
    7.  
    8.     void Start()
    9.     {
    10.         anim.Stop();
    11.     }
    12.  
    13.  
    14.     void OnMouseEnter()
    15.     {
    16.         anim.Play();
    17.     }
    18.     void OnMouseExit()
    19.     {
    20.         anim.Rewind();
    21.     }
    22. }
     
unityunity