PM_Player

PM_Player

Add to an pawn to allow it to be used as a player avatar by the player manager.

Note - PM_Player should be paired with AM_Player in the actor.

Members

# isMyPlayerPawn :boolean

Returns true if the pawn is the avatar of the local user. You can use this to create subscriptions so you can route control inputs to the proper actor. A pawn will listen for inputs only if belongs to the local user. Pawns that belong to other users won't subscribe to control inputs. You can also do things like rendering a different model if the pawn belongs to the local user.

Note: isMyPlayerPawn() checks the entire scene graph of the pawn. So a child of a player pawn will be reported as a player pawn as well.

Type:
  • boolean
Example:
class AvatarPawn extends mix(Pawn).with(PM_Player) {
     constructor(options) {
         super(options);
         if (this.isMyPlayerPawn) {
             this.subscribe("input", "wDown", () => this.say("forward"); // If the w key is pressed, tell my avatar to move forward.
         }
     }
}