- Home /
Unity2D Sync falling object with animation
I have an object that falls with gravity:
if (val == 1)
{
pillar1.GetComponent<Rigidbody2D>().velocity = new Vector2(-speed, GetComponent<Rigidbody2D>().velocity.x);
pillar1.GetComponent<Rigidbody2D>().gravityScale = 1;
}
Above this falling object I animate the sprite it to animate the path behind the fall:
if (pillar1.GetComponent<Rigidbody2D>().velocity.x > 1)
{
anim.Play("MovePillar");
}
What I cannot figure out is how can I time these together? As you can see in the image below the object falls out of time when the animation runs. What value can I plug into the animation?
2017-05-02-19h41-16.png
(26.6 kB)
2017-05-02-19h54-59.png
(49.1 kB)
Comment