mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-05 19:39:21 +00:00
More effective recovery
Fix of trigger detection
This commit is contained in:
parent
8d337635b8
commit
fa5a0334b9
4 changed files with 42 additions and 30 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue