using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Animations; namespace BITKit { public class Prop_Fixed : MonoBehaviour { [SerializeField] private new Rigidbody rigidbody; [SerializeField] private LayerMask allowLayer; private Collider _collider; private void Start() { if(rigidbody.isKinematic)Destroy(this); } private void Update() { if (!rigidbody.IsSleeping() || !_collider) return; if (_collider.gameObject.isStatic) { Destroy(this); return; } enabled = false; transform.SetParentConstraint(_collider.transform); rigidbody.isKinematic = true; } private void OnCollisionStay(Collision other) { if (allowLayer.value is not 0 && allowLayer.Includes(other.gameObject.layer) is false) return; _collider = other.collider; } } }