Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Reset runtimeAnimatorController script [Unity 2018.3.11 ]

Discussion in 'Scripting' started by catafest, Apr 2, 2019.

  1. catafest

    catafest

    Joined:
    May 3, 2014
    Posts:
    78
    I used the Unity version Unity 2018.3.11f1 (64-bit) personal edition and this come with some changes.
    I follow this video tutorial:
    and the example used not work on this Unity version is not work.
    The script used to enable/disable to run player movement in the tutorial:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Playables;
    5.  
    6. public class TimelineManager : MonoBehaviour
    7. {
    8.     private bool fix = false;
    9.     public Animator playerAnimator;
    10.     public RuntimeAnimatorController playerAnim;
    11.     public PlayableDirector director;
    12.     // Start is called before the first frame update
    13.     void OnEnable()
    14.     {
    15.         playerAnim = playerAnimator.runtimeAnimatorController;
    16.         playerAnimator.runtimeAnimatorController = null;
    17.     }
    18.     // Update is called once per frame
    19.     void Update()
    20.     {
    21.         if (director.state == PlayState.Playing)
    22.         {
    23.             fix = true;
    24.             playerAnimator.runtimeAnimatorController = playerAnim;
    25.         }
    26.     }
    27. }
    28.