| 12345678910111213141516171819202122232425262728 |
- using UdonSharp;
- using UnityEngine;
- using VRC.SDKBase;
- [UdonBehaviourSyncMode(BehaviourSyncMode.NoVariableSync)]
- [DisallowMultipleComponent]
- [AddComponentMenu("Artyom Scripting System/Checkpoint")]
- public class Checkpoint : UdonSharpBehaviour
- {
- public GameObject targetObject; // The game object to move
- // Each player has their own progress, so this stays local: syncing it let one player's checkpoint block everyone's
- private bool hasBeenUsed = false;
- public override void OnPlayerTriggerEnter(VRCPlayerApi player)
- {
- if (hasBeenUsed || !player.isLocal) return;
- if (targetObject == null)
- {
- Debug.LogError("[AUMSS] Checkpoint: Target Object isn't assigned.");
- return;
- }
- targetObject.transform.SetPositionAndRotation(transform.position, transform.rotation);
- hasBeenUsed = true;
- gameObject.SetActive(false); // Hides the checkpoint for this player once used
- }
- }
|