PlayerTrigger.cs 986 B

1234567891011121314151617181920212223242526272829303132
  1. 
  2. using UdonSharp;
  3. using UnityEngine;
  4. using VRC.SDKBase;
  5. using VRC.Udon;
  6. using System;
  7. [Obsolete("Replaced with Linked Object System")]
  8. [DisallowMultipleComponent]
  9. [AddComponentMenu("Artyom Scripting System/Pickup Following Mover Fix")]
  10. public class PlayerTrigger : UdonSharpBehaviour
  11. {
  12. public Animator targetAnimator; // The Animator component to control
  13. public string parameterName; // The name of the boolean parameter to change
  14. public override void OnPlayerTriggerStay(VRCPlayerApi player)
  15. {
  16. if (targetAnimator != null && !string.IsNullOrEmpty(parameterName))
  17. {
  18. targetAnimator.SetBool(parameterName, true); // Set the boolean parameter to true
  19. }
  20. }
  21. public override void OnPlayerTriggerExit(VRCPlayerApi player)
  22. {
  23. if (targetAnimator != null && !string.IsNullOrEmpty(parameterName))
  24. {
  25. targetAnimator.SetBool(parameterName, false); // Set the boolean parameter to false
  26. }
  27. }
  28. }