# PlayObjectAnimation

## Description

Plays an given animation on its parent object. Only objects loaded with LoadObjectWithChildren will have animations assigned to them. Animation names are defined by the modelling program when the animations were created, you can discover what the names are by using GetObjectAnimationName. The animation can be started and ended at any point in the animation using the start and end parameters, these are given in seconds, and if looping is turned on then the object will return to the given start time at the start of each loop. If you want the looping to be seamless then the bone positions at the start and end time must be exactly the same, as there will be no interpolation between them when it loops. The tweentime parameter can be used to interpolate between the current bone positions and the start time of the animation so that there is no sudden jump in bone positions. This tweening only happens once, it does not happen every loop, and does not contribute to the animation time. Essentially the animation is paused until tweening has finished. Note that as soon as this command is called the bones will be controlled by animation and cannot be moved with SetObjectBonePosition or similar commands. You can regain manual control of individual bones by using SetObjectBoneCanAnimate on it. You can regain control of the entire bone structure by using ResetObjectAnimation.

## Definition

PlayObjectAnimation( objID, animName, starttime, endtime, loop, tweentime )

void agk::PlayObjectAnimation( UINT objID, const char *animName, float starttime, float endtime, int loop, float tweentime )

## Parameters

- objID - The ID of the object to modify.
- animName - The name of the animation to play, defined by the modelling program
- starttime - The point in the animation at which the object should start playing, in seconds
- endtime - The point in the animation at which the object should stop playing, minus 1 to continue to the end
- loop - 1 to loop the animation forever, 0 to play once, any other positive integer to loop that many times
- tweentime - The time in seconds to transition from the objects current state to the first frame of animation