Reaction to CVRPointer component with ragdoll type

This commit is contained in:
SDraw 2023-04-11 00:18:41 +03:00
parent dfa7da50d6
commit faac28fb88
No known key found for this signature in database
GPG key ID: BB95B4DAB2BB8BB5
4 changed files with 75 additions and 1 deletions

42
ml_prm/RagdollTrigger.cs Normal file
View file

@ -0,0 +1,42 @@
using ABI.CCK.Components;
using UnityEngine;
namespace ml_prm
{
[DisallowMultipleComponent]
class RagdollTrigger : MonoBehaviour
{
static int ms_localPlayerLayer = 0;
Collider m_lastCollider = null;
bool m_triggered = false;
void Start()
{
ms_localPlayerLayer = LayerMask.NameToLayer("PlayerLocal");
}
void OnTriggerEnter(Collider p_other)
{
CVRPointer l_pointer = p_other.gameObject.GetComponent<CVRPointer>();
if((l_pointer != null) && l_pointer.type == "ragdoll" && p_other.gameObject.layer == ms_localPlayerLayer && (m_lastCollider != p_other))
{
m_lastCollider = p_other;
m_triggered = true;
}
}
void OnTriggerExit(Collider p_other)
{
if(m_lastCollider == p_other)
m_lastCollider = null;
}
public bool GetStateWithReset()
{
bool l_state = m_triggered;
m_triggered = false;
return l_state;
}
}
}