0
Answered

Animator does not affected by Chronos

AndTorch 3 years ago updated by Lazlo Bonin (Lead Developer) 2 years ago 3

Hi,

I have a very simple setup on my player's character: Animator controller and Timeline that looks at global clock called "Gameplay". When I change timeScale in inspector in play mode Animator continue playing with default speed.


I made a hack for this:

private void Awake()
{
    _animator = GetComponent<animator>();
    _timeline = GetComponent<timeline>();
}
private void Update()
{
    _animator.speed = _timeline.timeScale;
}

But I guess it's not how this suppose to work...

Could you help me with that issue? Thanks!

Chronos Version:
2.4.13
Unity Version:
2017.3.0f3

So, I found the problem. If you call timeline.CacheComponents() during Awake() or OnEnable() then all cached components will be null (animator, rigidbody, etc.) which is weird since all these components attached to gameobject in the inspector and exist when Awake() and OnEnable() fired.

Escalated

Hi AndTorch, sorry for the extremely late reply on this.

As you figured out, for performance reasons, Chronos does indeed cache components.

This is described in the documentation here: https://ludiq.io/chronos/documentation#localclock.CacheComponents

You only have to call CacheComponents after a change in the component list for Chronos to behave properly!