I try to animate a simple workstation, where an incoming MU is:
1. placed on a lift
2. the lift moves up
3. The lift rotates
4. The assembly is done(no animation)
5. The lift rotates back
6. The lift moves down
7. Mu leaves the station.
Steps 1 and 2 work well.
I use the selfanimation of the object "lift" in the station. It has a selfanimation "up" and "rotate" .
For step 2 I use in the entrance method of station ST104:
var ani:=ST104._3d.getObject("Lift").SelfAnimations; var MUani:=ST104._3D.MUAnimations; ani.up.schedule ani.playAnimation
After this step 3 should be performed. I tried to do it like this:
var ani:=ST104._3d.getObject("Lift").SelfAnimations; var MUani:=ST104._3D.MUAnimations; ani.up.schedule ani.playAnimation ani.rotation.schedule ani.playAnimation
However then the two animations are done at the same time, and the rotation is not completed until 90 degrees. This does work do, if I only use the rotation selfanimation.
For step 5 and 6 I want to do the animations backwards using false in the schedule like this:
var ani:=ST104._3d.getObject("Lift").SelfAnimations; var MUani:=ST104._3D.MUAnimations; ani.up.schedule(false) ani.playAnimation @.move(drain)
But then the animations dont play and the Mu leaves the station right away.
How do I solve the problems and can I use "Waituntil" to wait for the animation to finish.
Solved! Go to Solution.
Self animations are managed in blocks. This means that, as long as you do not start a new animation block, every newly scheduled is added to a previously existing one if there already is one.
Important to know here is that playAnimation only starts an animation in the sense that the time when playAnimation is called, is remembered to correctly play the animation in the following simulation.
For your step 3, this means that the first call to playAnimation has no immediate effect. I think, what you try to do is to let Plant Simulation wait for finishing the first animation to start the second one.
This can be done with the following code instead:
var ani:=ST104._3d.getObject("Lift").SelfAnimations; ani.up.schedule ani.startNextAnimationBlock ani.rotation.schedule ani.playAnimation
Now, if simulation events are done between different animations, I find it best to manage if the code starts with a call to ani.resetAnimation to set the animations to a defined, unanimated, state.
About your last question: There is no waituntil to wait for animations to be finished, but you can ask how long animations will still take, so you can wait such a timespan:
var t := ani.EstimatedTotalAnimationTime wait t
In your example, this might look like this:
var ani:=ST104._3d.getObject("Lift").SelfAnimations; ani.up.schedule(false) ani.playAnimation wait ani.EstimatedTotalAnimationTime @.move(drain)
That is correct - if you do not pass the parameter, an animation is played in forward direction. If you pass it, it is played forward in case of false being passen and backwards in case of true being passed.