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

Sychronization of animations

Discussion in 'Scripting' started by activate_mc, Jun 28, 2011.

  1. activate_mc

    activate_mc

    Joined:
    Jun 1, 2011
    Posts:
    9
    Hi guys,

    I have a quick question with regards to animation playing.

    If I were to execute the following codes:

    gameobject1.animation.Play("animation1");
    gameobject2.animation.Play("animation2");
    gameobject3.animation.Play("animation3");

    Will all 3 game objects play the animation at the same time?

    Thanks in advance.
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Hi, welcome to the forum!

    Yes, if you make all three calls together like that then the animations will be synchronised.
     
  3. activate_mc

    activate_mc

    Joined:
    Jun 1, 2011
    Posts:
    9
    Hi Andeee,

    The timing of my animations seems to be a bit off. I suspect it could be due to the animations been executed in sequence thus the last animation get executed slightly slower than the first. (though they still do run concurrently)
     
  4. Sycle

    Sycle

    Joined:
    Nov 24, 2009
    Posts:
    446
    That's not how script execution works, those animations will all start playing on the same time. (if you put them in a different order you should see no difference)

    If your animations are out of sync, I would check your animations first and make sure they really are in sync, then investigate if there is any reason why any of the objects wouldn't be able to start playing their animation immediately. (although Play should trump everything except an animation on a higher level)
     
  5. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    If they loop and aren't the same frame size then do not expect them to match up...
     
  6. activate_mc

    activate_mc

    Joined:
    Jun 1, 2011
    Posts:
    9

    Thanks for the explanation. :)