Table of Contents

Class SwitchTargetMover

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

A ISwitchTarget that slides and/or rotates a transform between a closed pose and an open pose — a door, a portcullis, a drawbridge, a moving platform.

public class SwitchTargetMover : MonoBehaviour, ISwitchTarget
Inheritance
Object
Component
Behaviour
MonoBehaviour
SwitchTargetMover
Implements
Inherited Members
MonoBehaviour.IsInvoking()
MonoBehaviour.CancelInvoke()
MonoBehaviour.StopCoroutine(Coroutine)
MonoBehaviour.StopAllCoroutines()
MonoBehaviour.destroyCancellationToken
MonoBehaviour.useGUILayout
MonoBehaviour.didStart
MonoBehaviour.didAwake
MonoBehaviour.runInEditMode
Behaviour.enabled
Behaviour.isActiveAndEnabled
Component.GetComponent<T>()
Component.TryGetComponent<T>(out T)
Component.GetComponentInChildren<T>()
Component.GetComponentsInChildren<T>()
Component.GetComponentInParent<T>()
Component.GetComponentsInParent<T>()
Component.GetComponents<T>()
Component.GetComponentIndex()
Component.CompareTag(TagHandle)
Component.transform
Component.transformHandle
Component.gameObject
Component.tag
Object.GetEntityId()
Object.GetInstanceID()
Object.GetHashCode()
Object.InstantiateAsync<T>(T)
Object.InstantiateAsync<T>(T, Transform)
Object.InstantiateAsync<T>(T, Vector3, Quaternion)
Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion, Transform)
Object.Instantiate(Object)
Object.Instantiate(Object, Scene)
Object.Instantiate<T>(T, InstantiateParameters)
Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
Object.Instantiate(Object, Transform)
Object.Instantiate<T>(T)
Object.Instantiate<T>(T, Vector3, Quaternion)
Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
Object.Instantiate<T>(T, Transform)
Object.Destroy(Object)
Object.DestroyImmediate(Object)
Object.DontDestroyOnLoad(Object)
Object.DestroyObject(Object)
Object.FindObjectsOfType<T>()
Object.FindObjectsByType<T>(FindObjectsSortMode)
Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
Object.FindObjectOfType<T>()
Object.FindFirstObjectByType<T>()
Object.FindAnyObjectByType<T>()
Object.FindFirstObjectByType<T>(FindObjectsInactive)
Object.FindAnyObjectByType<T>(FindObjectsInactive)
Object.FindObjectsByType<T>()
Object.FindObjectsByType<T>(FindObjectsInactive)
Object.ToString()
Object.name
Object.hideFlags

Remarks

The closed pose is wherever the moved transform sits when the scene loads, so a designer places the door shut and describes only the offset that opens it. Offsets are local to the moved transform's parent, so a door rotated to fit a wall opens along its own axis rather than a world one.

The motion is driven in Update on both peers rather than replicated per-frame. Only the switch's state crosses the wire — once, when it changes — and each peer plays the same deterministic interpolation from wherever it currently is. A client that arrives mid-swing, or misses the message entirely and gets the state from the spawn payload, converges on the correct end pose instead of holding a wrong one.

The server moves too, and must: this transform carries the collider the character controller tests against, so a door that only opened on clients would be an invisible wall.

Properties

IsActivated

Whether this target is currently in the activated state.

public bool IsActivated { get; }

Property Value

bool

Methods

Activate(IPlayerCharacter)

Activates this target (e.g., opens a door, unlocks a chest, disarms a trap).

public void Activate(IPlayerCharacter activator)

Parameters

activator IPlayerCharacter

The player character who triggered the switch.

Deactivate(IPlayerCharacter)

Deactivates this target (e.g., closes a door, locks a chest, re-arms a trap).

public void Deactivate(IPlayerCharacter activator)

Parameters

activator IPlayerCharacter

The player character who triggered the switch.

SnapTo(bool)

Puts this target into the given state with no transition.

public void SnapTo(bool activated)

Parameters

activated bool

The state to adopt immediately.

Remarks

For catching up rather than for reacting. A client that starts observing a switch reads the switch's current state out of its spawn payload, and that state describes something that happened before the player arrived — possibly hours before. Replaying it through Activate(IPlayerCharacter) would play the transition too, so walking into a room would set every door in it swinging. Nothing on the interaction path calls this.