TeleporterHandler - jimdroberts/FishMMO GitHub Wiki
TeleporterHandler
handles interactions with teleporter objects on the server in FishMMO. It allows players to teleport to target locations or named destinations.
-
public void HandleInteraction(IInteractable interactable, IPlayerCharacter character, ISceneObject sceneObject, InteractableSystem serverInstance)
Handles the interaction between a player character and a teleporter. If a target transform is set, moves the character to the target position and rotation. Otherwise, triggers teleport by name. Parameters: - IInteractable interactable: The interactable object (should be a Teleporter). - IPlayerCharacter character: The player character interacting with the teleporter. - ISceneObject sceneObject: The scene object associated with the interaction. - InteractableSystem serverInstance: The server instance managing interactables.
- Register
TeleporterHandler
as the handler for teleporter interactables on the server. - The handler will automatically process player interactions and move or teleport the character as appropriate.
// Example 1: Handling a teleporter interaction
teleporterHandler.HandleInteraction(interactable, character, sceneObject, serverInstance);
- Ensure the handler is registered for the correct interactable types.
- Validate that the character is not already teleporting before processing the interaction.
- Use target transforms for direct movement or named destinations for flexible teleport logic.