Forum Discussion

motorsep's avatar
motorsep
Member
2 months ago
Solved

Available animations for NPCs ?

I finally got an NPC (avatar) running around my world. Now I am wondering where do I find list of all available animations for NPC avatars. For example, if I need for NPC to grab a weapon, how do I know what animations for holding sword, axe, pistol, shotgun, etc. are called and what they look like?

  • const npc = this.entity.as(npcs.Npc);
    npc.tryGetPlayer().then((player) => 
      { 
        player?.playAvatarGripPoseAnimationByName(AvatarGripPoseAnimationNames.Fire);
      });

    From the NPC's entity, cast it to an NPC type. You can then use "tryGetPlayer()" to get the player (or not!). Note this is a promise so you'll have to call ".then" to do some action when the function has done its asynchronous work.

    This player will have the "playAvatarGripPoseAnimationByName" function with which you can trigger these animations. Instead of remembering the string names, use the AvatarGripPoseAnimationNames enum and use its discrete set of values.

    Also my advice would be to cache this player at the start so you don't have to use this promise each time you want to trigger the anim

    https://developers.meta.com/horizon-worlds/learn/documentation/create-for-web-and-mobile/typescript-apis-for-mobile/player-animations

     

2 Replies

  • const npc = this.entity.as(npcs.Npc);
    npc.tryGetPlayer().then((player) => 
      { 
        player?.playAvatarGripPoseAnimationByName(AvatarGripPoseAnimationNames.Fire);
      });

    From the NPC's entity, cast it to an NPC type. You can then use "tryGetPlayer()" to get the player (or not!). Note this is a promise so you'll have to call ".then" to do some action when the function has done its asynchronous work.

    This player will have the "playAvatarGripPoseAnimationByName" function with which you can trigger these animations. Instead of remembering the string names, use the AvatarGripPoseAnimationNames enum and use its discrete set of values.

    Also my advice would be to cache this player at the start so you don't have to use this promise each time you want to trigger the anim

    https://developers.meta.com/horizon-worlds/learn/documentation/create-for-web-and-mobile/typescript-apis-for-mobile/player-animations

     

  • ava.9146's avatar
    ava.9146
    Honored Guest

    There’s no public list yet — NPC animations are still limited. You can use only basic preset animations like idle, walk, run, and gesture types provided in the editor. Custom weapon-holding or action animations aren’t officially supported yet.