Player Animations
Since the firing of projectiles is controlled programmatically, you can add hooks in your code to play animations. These animations play only when visiting Meta Horizon Worlds on web and mobile.
You can trigger the animation using playAvatarGripPoseAnimationByName().
player.playAvatarGripPoseAnimationByName(AvatarGripPoseAnimationNames.Fire);
You can find the names of the supported animations in the AvatarGripPoseAnimationNames enumeration. Some animations will have a variation based on the pose type from the AvatarGripPose enumeration. You can see the pose type in the properties of the grabbable entity.
/**
* Defines the available avatar grip pose animations.
*/
export enum AvatarGripPoseAnimationNames {
/**
* Fire animation for the player.
*/
Fire = 'Fire',
/**
* Reload animation for the player.
*/
Reload = 'Reload',
}
A script triggering an animation for a player when an event is received would look something like this:
const playAnimationEvent = new CodeBlockEvent<
[player: Player, animation: string]
>('playAnimation', [PropTypes.Player, PropTypes.String]);
class PlayAnimation extends Component<Props> {
start() {
this.connectCodeBlockEvent(
this.entity,
playAnimationEvent,
(player: Player, animation: string) => {
player.playAvatarGripPoseAnimationByName(animation);
},
);
}
}
Component.register(PlayAnimation);