Hello,
I’ve spent many hours reading the Animation manual and browsing Unity answers and I think I have taken the wrong approach for my implementation. Could you please orientate somebody new in Mecanim? Thanks in advance.
I have a Clock clip, running from 12am to 12pm. I want to be able to initialize the animation so it starts at the time of the day I want. For this purpose, I have implemented a ClockRunningBehaviour class and I want to change the time OnStateEnter().
I have found a function, AnimationState.time, which should provide the functionality I need. However, I don’t know how to get my AnimationState object OnStateEnter():
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
Animation animation = animator.GetComponent<Animation>();
foreach (AnimationState state in animation)
{
// This is never hit, there are not AnimationStates!
//state.time = desiredTime;
}
}
Is my approach correct? How would you implement a Clock (provided the animation clip)? Thanks!