Skip to main content

PlayerActor [Abstract Base]

The PlayerActor is a networked, extensible character base for player-controlled entities in the game, integrating Fusion networking, modular avatar customization, state machines, camera control, and interaction systems.


๐ŸŽญ Core Overviewโ€‹

public abstract class PlayerActor : NetworkBehaviour, IPlayerActor, IStateMachineOwner

Represents a networked player character capable of:

  • Performing interactions
  • Running primary/secondary state machines
  • Managing visual and camera systems
  • Supporting fast travel, teleportation, and avatar customization

๐Ÿ‘ฅ Identity & Avatarโ€‹

PlayerActorTypeโ€‹

public enum PlayerActorType { Human, Drone }

Represents the actorโ€™s logical role.

SetDisplayName(string newName)โ€‹

Sets the player's display name in the world.

AvatarUpdated_Rpc(int skinToneIndex, string[] details)โ€‹

Syncs avatar details across the network and rebuilds visuals.

DisplayActiveClothing(List<PlayerItem_SO> overrideList = null)โ€‹

Loads and displays the actor's visual representation.


๐ŸŽฎ Interaction Systemโ€‹

AvailableInteractionsโ€‹

Stores a mapping of interaction points to possible PlayerInteractions.

Interaction Methodsโ€‹

  • RegisterInteractions(point, ...)
  • UnregisterInteraction(...)
  • ClearInteractions()
  • ActionPressed(...)
  • PerformAction(...)

Automatically shows interaction options and invokes matching responses.


๐ŸŽฅ Camera Handlingโ€‹

ActivateCamera()โ€‹

Instantiates and configures a camera system with support for:

  • Mouse zoom
  • Touch gestures
  • Gamepad inputs

GetActiveCamera()โ€‹

Returns the current camera instance for this actor.


๐Ÿง  State Machinesโ€‹

Implements two layered state machines:

  • Primary State Machine: Controls movement or player-driven behavior.
  • Secondary State Machine: Handles hand or tool interactions.

Initializationโ€‹

CollectStateMachines(List<IStateMachine> stateMachines)

Transitioningโ€‹

RequestState<T>(), RequestSecondaryState<T>()
RequestStateByKey(string), ForceStateAsHost<T>()

Uses RPCs to request state transitions on the server when needed.


๐Ÿง Movement & Teleportationโ€‹

Teleport(Vector3 position, Vector3 rotation, bool lockKCC)โ€‹

Moves the player to a specified location. If lockKCC is true, disables the controller post-teleport.


โค๏ธ Health Management (Abstract)โ€‹

You must implement:

  • UseHealth(int amount)
  • GetHealth()
  • SetHealth(int amount)
  • GetMaxHealth()

๐Ÿ”— Network & Host Syncโ€‹

PlayerConnectionHost connectionHostโ€‹

Holds metadata about the player, including identity, XP, respawn, etc.

SetConnectionHost(...)โ€‹

Links a host to this actor.


๐ŸŒ Network Lifecycleโ€‹

Spawned(), Despawned()โ€‹

Triggers visual registration, location restoration, and multiplayer service hooks.

Render()โ€‹

Listens for avatar or host changes to update clothing and display name.


๐Ÿงฌ Interface: IPlayerActorโ€‹

Defines shared behaviors for polymorphic use across systems:

interface IPlayerActor {
Dictionary<PlayerInteractionPoint, PlayerInteraction[]> AvailableInteractions { get; }
PlayerActorType GetType();
bool CanEnterDialog();
void EnterDialogState(DialogStateMachine stateMachine);
PlayerBehaviourMachine GetMainStateMachine();
PlayerBehaviourMachine GetSecondaryStateMachine();
}

๐Ÿงฉ Summaryโ€‹

PlayerActor is the spine of character logic in the m00m world. It enables multiplayer-ready avatars with rich interaction, animation, and customization layers. Extend this class to implement unique gameplay roles (e.g., drones, NPCs, special agents) while inheriting the common systems for interaction, camera, and control.