Checkpoint.cs 670 B

1234567891011121314151617181920212223242526
  1. using UdonSharp;
  2. using UnityEngine;
  3. using VRC.SDKBase;
  4. using VRC.Udon;
  5. using System;
  6. [DisallowMultipleComponent]
  7. [AddComponentMenu("Artyom Scripting System/Checkpoint")]
  8. public class Checkpoint : UdonSharpBehaviour
  9. {
  10. public GameObject targetObject; // The game object to move
  11. [UdonSynced]
  12. private bool hasBeenUsed = false;
  13. public override void OnPlayerTriggerEnter(VRCPlayerApi player)
  14. {
  15. if (hasBeenUsed || !player.isLocal) return;
  16. targetObject.transform.SetPositionAndRotation(transform.position, transform.rotation);
  17. hasBeenUsed = true;
  18. gameObject.SetActive(false); // Disables the script after use
  19. }
  20. }