Firstborn/Assets/RPG Creation Kit/Scripts/AI/NavMeshComponents/Examples/Scripts/EnableIffSleeping.cs
Schaken-Mods 959e80cf72 assets upload
assets upload description.
2023-03-28 12:16:30 -05:00

27 lines
618 B
C#

using UnityEngine;
// Enables a behaviour when a rigidbody settles movement
// otherwise disables the behaviour
public class EnableIffSleeping : MonoBehaviour
{
public Behaviour m_Behaviour;
Rigidbody m_Rigidbody;
void Start()
{
m_Rigidbody = GetComponent<Rigidbody>();
}
void Update()
{
if (m_Rigidbody == null || m_Behaviour == null)
return;
if (m_Rigidbody.IsSleeping() && !m_Behaviour.enabled)
m_Behaviour.enabled = true;
if (!m_Rigidbody.IsSleeping() && m_Behaviour.enabled)
m_Behaviour.enabled = false;
}
}