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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Animation.Rewind(); Not Working

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

  1. Olric37

    Olric37

    Joined:
    Apr 5, 2021
    Posts:
    2
    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. }