Search Unity

Non-instant animation

Discussion in 'Animation' started by maxituc369, Mar 7, 2017.

  1. maxituc369

    maxituc369

    Joined:
    Mar 7, 2017
    Posts:
    3
    Hello,

    I'm beginner with unity and i'm still more a begginer for animation :)

    My problem is strange, i want change the speed of animation to négative speed for reverse the animation, that works but its not instané.

    I record this :




    The multiplier speed is correctly change but , i don't understand why this is not instantaneous.


    This is the code i use :
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class opendoor : MonoBehaviour {
    6.     public List<GameObject> electricite;
    7.  
    8.     public Animator aniopen;
    9.  
    10.     public bool alimente = false;
    11.  
    12.     private bool prealim = false;
    13.     // Use this for initialization
    14.     void Start () {
    15.         //aniopen.speed = 0;
    16.     }
    17.    
    18.     // Update is called once per frame
    19.     void Update () {
    20.         prealim = true;
    21.         foreach (GameObject activateur in electricite)
    22.         {
    23.             if (activateur != null)
    24.             {
    25.                 elec scriptactivateur = activateur.GetComponent<elec>();
    26.                 if (scriptactivateur.electricity == false)
    27.                 {
    28.                     prealim = false;
    29.                  
    30.                 }
    31.             }
    32.         }
    33.         if (prealim)
    34.         {
    35.             alimente = true;
    36.             aniopen.SetFloat("mouvementspeed",  1);
    37.          
    38.  
    39.         }
    40.         else
    41.         {
    42.             alimente = false;
    43.            
    44.             aniopen.SetFloat("mouvementspeed", - 3);
    45.  
    46.         }
    47.         print(alimente);
    48.     }
    49. }
    50.  
     
  2. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    I'm not sure, but I think your animation's current time is in the negative.
    So it has to go back to 0, then it will play.