using UdonSharp; using UnityEngine; using UnityEngine.Animations; using VRC.SDK3.ClientSim; using VRC.SDKBase; using VRC.Udon; public class Horseshoe : UdonSharpBehaviour { private bool IsBeingHeld = false; [UdonSynced, FieldChangeCallback(nameof(SetIsInHome))] private bool IsInHome = true; private ParentConstraint HorseshoeConstraint; private Rigidbody HorseshoeRigidBody; public void Start() { HorseshoeConstraint = GetComponent(); HorseshoeRigidBody = GetComponent(); } public override void OnPickup() { Networking.SetOwner(Networking.LocalPlayer, gameObject); IsBeingHeld = true; EnableConstraints(false); RequestSerialization(); base.OnPickup(); } public override void OnDrop() { IsBeingHeld = false; if (IsInHome) { EnableConstraints(true); } else { EnableConstraints(false); } RequestSerialization(); base.OnDrop(); } private void EnableConstraints(bool enable) { HorseshoeRigidBody.useGravity = !enable; HorseshoeConstraint.enabled = enable; } public bool SetIsInHome { set { IsInHome = value; if (!IsBeingHeld && IsInHome) { EnableConstraints(true); } } get => IsInHome; } }