# Scripted animation and physics

**URL:** <https://discussions.unity.com/t/scripted-animation-and-physics/402376>\
**Category:** Animation\
**Tags:** Scripting\
**Created:** [November 24, 2009, 5:08pm UTC](https://discussions.unity.com/t/scripted-animation-and-physics/402376 "2009-11-24T17:08:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PatHightree1](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/pathightree1/32/109065_2.png) [@PatHightree1](https://discussions.unity.com/u/PatHightree1)\
**Post date:** [November 24, 2009, 5:08pm UTC](https://discussions.unity.com/t/scripted-animation-and-physics/402376/1 "2009-11-24T17:08:21Z")

</div>

I am trying to animate hydrolic machines that will interact with pipes.  
The animation is based on simulation data that is received over the network.  
To animate a machine I do the following :  
In FixedUpdate() I set the animation

```auto
AnimationState MyAnimationState = this.animation["Take 001"];

MyAnimationState.enabled = true;
MyAnimationState.time = PositionToTime(desiredPos);
this.animation.Sample();
MyAnimationState.enabled = false;

```

But when I read back the animation time (still in FixedUpdate) I get the same time for the whole frame.

This leads me to believe that the animation system is updated once per frame.  
Can anybody confirm/deny this ?  
Any suggestions on how improve this ?

---

<div class="post-metadata">

**Author:** ![PatHightree1](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/pathightree1/32/109065_2.png) [@PatHightree1](https://discussions.unity.com/u/PatHightree1)\
**Post date:** [November 25, 2009, 9:53am UTC](https://discussions.unity.com/t/scripted-animation-and-physics/402376/2 "2009-11-25T09:53:04Z")

</div>

I tried to find out where the animation is performed in the execution loop, but the [wiki page](http://www.unifycommunity.com/wiki/index.php?title=Updated_Event_Execution_Order) doesn’t shed any light on this.  
Can anybody tell me more ?

---

<div class="post-metadata">

**Author:** ![PatHightree1](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/pathightree1/32/109065_2.png) [@PatHightree1](https://discussions.unity.com/u/PatHightree1)\
**Post date:** [November 25, 2009, 12:05pm UTC](https://discussions.unity.com/t/scripted-animation-and-physics/402376/3 "2009-11-25T12:05:18Z")

</div>

Never mind, there was a bug in my own code that prevented the animation sampling.
