init
This commit is contained in:
commit
341a877b4a
2338 changed files with 1346408 additions and 0 deletions
26
Assets/NavMesh/Examples/Scripts/EnableIffSleeping.cs
Normal file
26
Assets/NavMesh/Examples/Scripts/EnableIffSleeping.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue