Overriding The Avatar Pose
You can programmatically override the Avatar Pose on a grabbable at runtime. This approach lets you play a different set of animations. For example, you could use a gun in a melee attack by switching to the sword set. The calls required are:
- setAvatarGripPoseOverride(AvatarPose)
- clearAvatarGripPoseOverride()
The existing avatar grip poses are defined as follows:
export declare enum AvatarGripPose {
Default = 'Default', // The Default grip type.
Pistol = 'Pistol', // Held in a pistol grip.
Shotgun = 'Shotgun', // Held in a shotgun grip.
Rifle = 'Rifle', // Held in a rifle grip.
RPG = 'RPG', // Held in an RPG grip.
Sword = 'Sword', // Held in a sword grip.
}
An example of usage might be as followed:
fireGun(player: Player) {
if(this.player2p && this.player2p.id == player.id) {
// Switch back to the default animation set
this.player2p.clearAvatarPoseOverride();
this.player2p.playAvatarPoseAnimationByName(AvatarPoseAnimationNames.Fire);
}
}
meleeAttack(player: Player) {
if(this.player2p && this.player2p.id == player.id) {
// Switch to using the sword animation set
this.player2p.setAvatarPoseOverride(AvatarPose.Sword);
this.player2p.playAvatarPoseAnimationByName(AvatarPoseAnimationNames.Fire);
}
}