- Home /
How to start animation with different cycle offsets (2d)?
Using Unity 5, mecanim animation on sprites, with state machines and transitions and all that good stuff.
I have a multilegged character, and I'm trying to build a prefab for a single leg that I can use four times. But I want the animations for each leg to start at a different offset.
I have the state machine, transitions, etc. all working fine. But each of the four legs animates at the same time. What I really want to do is start the back leg animations halfway through the animation cycle.
I found Cycle Offset -- but it's a setting on the animation, and I don't know how or where is the right place to set it in code. I thought it would be something I could set in a state behavior's OnStateEnter, but I can't find a method call that works.
I found that you could set it using animator.Play(), but... that doesn't seem compatible with the state machine + transition approach.
Edit: I tried using Play() in OnStateEnter, but it looks like that triggers the state again as it gets into an endless loop of starting the animation over and over.
Ideas? Suggestions?
Your answer
Follow this Question
Related Questions
Does the cycle offset also work on sprite based animations? 1 Answer
How do you check to see if an animation is playing in a Sub-State machine? 0 Answers
Select Animations Freezing on First Frame 1 Answer
Duplicating and Tweaking Mecanim 2D Animations 1 Answer
Getting with the times... learning Mechanim/Animator 1 Answer