Playing on any animator
PlayOn and StopOn work like Play and Stop, but they take an Animator instead of an NPC id. They are meant for figures your mod owns, such as extras (see Mod NPCs).
NpcAnimation clips on any animator
Call PlayOn with an animator that is not on a scene NPC, and StopOn to fade that clip out.
public static class NpcAnimation
{
public static bool PlayOn(string modId, Animator animator, AnimationClip clip, bool loop, float fadeSeconds = 0.2f);
public static bool StopOn(string modId, Animator animator, float fadeSeconds = 0.2f);
}
| Method | Returns | What it does |
|---|---|---|
PlayOn(modId, animator, clip, loop, fadeSeconds) | bool | Starts a clip on an animator. |
StopOn(modId, animator, fadeSeconds) | bool | Fades that clip out. |
Things to know
PlayOnworks on any switched-on animator that is not part of a scene NPC. It also accepts the animators of props. It givesfalsefor an animator that is switched off and for one that belongs to a scene NPC. Play a clip on a scene NPC withPlayonly. Playing on the player’s own model is not supported. (It refuses an animator that has anNPCInfoamong its parents, so the player’s rig and props are accepted but not supported as a target.)- A
nullanimator throws an error, and an animator that was destroyed givesfalse. The error is anArgumentNullExceptionnamedanimator. - The other rules are the same as for
Play. There is one clip for each animator, the fades work the same way, and a scene load ends the clip. PlayandStopdo not see a clip started byPlayOn, andStopOndoes not see a clip started byPlay.