More effective recovery

Fix of trigger detection
This commit is contained in:
SDraw 2023-04-14 11:00:20 +03:00
parent 8d337635b8
commit fa5a0334b9
No known key found for this signature in database
GPG key ID: BB95B4DAB2BB8BB5
4 changed files with 42 additions and 30 deletions

View file

@ -6,23 +6,43 @@ namespace ml_prm
[DisallowMultipleComponent]
class RagdollTrigger : MonoBehaviour
{
Collider m_lastCollider = null;
Collider m_collider = null;
Collider m_lastTrigger = null;
bool m_triggered = false;
void Start()
{
m_collider = this.GetComponent<Collider>();
}
void Update()
{
if(!ReferenceEquals(m_lastTrigger, null))
{
if(m_lastTrigger != null)
{
if(!m_collider.bounds.Intersects(m_lastTrigger.bounds))
m_lastTrigger = null;
}
else
m_lastTrigger = null;
}
}
void OnTriggerEnter(Collider p_other)
{
CVRPointer l_pointer = p_other.gameObject.GetComponent<CVRPointer>();
if((l_pointer != null) && (l_pointer.type == "ragdoll") && (m_lastCollider != p_other))
CVRPointer l_pointer = p_other.GetComponent<CVRPointer>();
if((l_pointer != null) && (l_pointer.type == "ragdoll") && (m_lastTrigger != p_other))
{
m_lastCollider = p_other;
m_lastTrigger = p_other;
m_triggered = true;
}
}
void OnTriggerExit(Collider p_other)
{
if(m_lastCollider == p_other)
m_lastCollider = null;
if(m_lastTrigger == p_other)
m_lastTrigger = null;
}
public bool GetStateWithReset()