Skip to main content

TeleportationPoint

A class in Root.Township, the global namespace.

Custom teleport target: when the local player's teleporter points at it, moves them to a saved target position instead. The target and mode are saved and synced to players.

Constructors​

MemberWhat it is
TeleportationPoint()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

4 private and internal fields
MemberWhat it is
private GameObject effectObject shown while a teleporter aims at this point.
private MethodSync syncMethod sync for the target position and mode.
private Transform targetTransform the player is sent to.
private TeleportMode teleportModeHow the target is applied (feet by default).

Methods​

MemberWhat it is
override bool Attempt(Teleporter teleporter)Teleports the player if the teleporter belongs to a PlayerCharacter; returns whether it did.
override void Begin(Teleporter teleporter)Shows the effect while a teleporter aims here.
override void End(Teleporter teleporter)Hides the effect.
override void Initialize()Sets up the method sync for the target.
override void OnConnected(Player player)Server: sends the target position and mode to the joining player.
void PositionTarget(Vector3 position)Moves the target to a world position and syncs it to players in the chunk.
void TeleportPlayer(PlayerController playerController)Client: moves the local player to the target with the chosen TeleportMode. Does nothing for other players.
3 private and internal methods
MemberWhat it is
private void Awake()Hides the effect.
private void Serialize(Stream stream)Writes or reads the target position and teleport mode; remote clients apply what they read.
private void Sync(IPlayer player, Stream stream)Method sync handler that calls Serialize.