How to prevent animation sync on duplicated object
I have an object that has an animator, inside has one simple animation, move up and down in loop and other animation which is IDLE, no movement at all.
Now I want to have a lots of this same object jumping up and down, but each of them will make transition from idle to movement at different time so i have this script attachet to them
public float AnimationStartOffset;
public Animator animator;
private float next_start_floating;
private bool isStart = false;
// Use this for initialization
void Start () {
next_start_floating = Time.time + AnimationStartOffset;
}
// Update is called once per frame
void Update () {
if(Time.time > next_start_floating && !isStart)
{
animator.SetBool("IsJumping", true);
isStart = true;
}
}
I set the offset value differently to each object, but the animation of some objects are always start at same time, I also try to the the transition to no exit time, and using StartCoroutine, but the result is same.
Please help
Answer by nenorse · Jan 11 at 11:46 PM
for anyone still needing this:
public class PlayFromOffset: MonoBehaviour
{
// Start is called before the first frame update
private Animator anim;
public float frameOffset = 10;
public string stateName = "Walk_RM";
private const int ALL_LAYERS = 0;
void Start()
{
anim = GetComponent<Animator>();
anim.Play(stateName, ALL_LAYERS, frameOffset);
}
}
Make sure your gameobject has an animator component on it... and set the stateName to your named animation from your controller.
Your answer

Follow this Question
Related Questions
Whole rig moves down on transition between two animations. 0 Answers
Mechanim animation doesn't play 2 Answers
How do I show "Duration in" and "Duration out" for the transition graph in the inspector window 0 Answers
Mecanim: 2-step transitions in a single update (skip intermediate state) 0 Answers
How to Play random animation for Attack 5 Answers