Getting an Actor's State

While an Actor is playing, one can easily-enough query its current animation and frame.

But it seems that, once the animation stops, said information is no longer available.

Now, at first blush this makes sense: after all, once the animation stops the Actor is no longer playing an animation, and so there is no current animation.

However, it incurs a problem when it comes to restoring the state of the Actor (as after a load of a save-game): If there’s no record of the last animation to be played, and if that animation leaves the Actor in a specific pose, then how does one go about saving that state for later restoration?

Is there a function that I’m missing somewhere…?

[edit]
*Bump* Is this something that’s possible…? Or is it a case in which we have to store such state ourselves…?

[edit 2]
Thinking about this further, a problem has occurred to me–or rather, two: animation-blending and half-body animation.

In both cases, if I’m not much mistaken, it’s possible to have more than one animation affecting the skeleton of an Actor.

As a result, the most recent animation and frame-number doesn’t necessarily give the full pose of an Actor.

I’m starting to think that the only really comprehensive way to save the pose of an Actor is then to manually “exposeJoint”-ing every bone in the skeleton and record its transform; restoring the pose of the Actor would then presumably call for manually “controlJoint”-ing every bone and setting its transform. (In both cases presumably then releasing the exposure/control.)

In my specific, current case, I doubt that I’ll need to handle blending or half-body animations. As a result, it may be better for me to just alter my interface with the relevant set of Actors such that I can myself record the name of each animation that is played or posed on each Actor…

(As to the frame, I suppose that I can check whether the recorded animation-name is still playing. If so, then I can use its current frame; if not, then I can use its first or last frame (depending on animation speed). In the case of posing, I might record the frame at pose-time.)

However, I think you are complicating your task. In fact, you need to store the FSM stage that caused this animation. Since in games, usually behind-the-scenes animation that is not produced is in the t-pose, when it hits the frame it is played directly depending on the state of the logic that is needed. For example, an actor was caught walking.

That is a good point, actually!

This wasn’t immediately obvious to me, as I’m doing this is for Actors that aren’t attached to full game-objects, or at least not directly.

Such Actors tend to be notionally parts of the scenery, and are managed by their level-object.

(For full game-objects I do have effectively what you describe: animation is prompted by the FSM of the game-object.)

However, your post prompts me to realise: any such Actor is likely driven by the scripting of the level. As a result, I should be able to just save the relevant data with the level’s data, and from that apply an appropriate animation-state.

So thank you for your post! :slight_smile: