This commit is contained in:
CortexCore
2023-12-03 17:35:43 +08:00
parent ba342d6627
commit ba9f4eda80
702 changed files with 162078 additions and 21050 deletions

View File

@@ -0,0 +1,40 @@
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;
}
}
}