34 lines
644 B
C#
34 lines
644 B
C#
using UnityEngine;
|
|
|
|
public class TransformTarget : MonoBehaviour
|
|
{
|
|
public Transform Target;
|
|
|
|
private Rigidbody _Rb;
|
|
|
|
public Rigidbody RBody => _Rb;
|
|
|
|
public void Initialize(Transform target)
|
|
{
|
|
Target = target;
|
|
_Rb = base.gameObject.AddComponent<Rigidbody>();
|
|
_Rb.useGravity = false;
|
|
_Rb.isKinematic = true;
|
|
_Rb.mass = 1f;
|
|
}
|
|
|
|
public void DestroyHandler()
|
|
{
|
|
Object.Destroy(base.gameObject);
|
|
}
|
|
|
|
private void LateUpdate()
|
|
{
|
|
if (!(Target == null))
|
|
{
|
|
Target.GetPositionAndRotation(out var position, out var _);
|
|
base.transform.position = Vector3.Slerp(base.transform.position, position, Time.deltaTime * 60f);
|
|
}
|
|
}
|
|
}
|