Files
XCEngine/managed/GameScripts/PhysicsEventProbe.cs

55 lines
1.5 KiB
C#

using XCEngine;
namespace Gameplay
{
public class PhysicsEventProbe : MonoBehaviour
{
public int CollisionEnterCount;
public int CollisionStayCount;
public int CollisionExitCount;
public int TriggerEnterCount;
public int TriggerStayCount;
public int TriggerExitCount;
public bool CollisionStayFallbackInvoked;
public bool TriggerStayFallbackInvoked;
public string LastCollisionOtherName = string.Empty;
public string LastTriggerOtherName = string.Empty;
private void OnCollisionEnter(GameObject other)
{
CollisionEnterCount++;
LastCollisionOtherName = other != null ? other.name : string.Empty;
}
private void OnCollisionStay()
{
CollisionStayCount++;
CollisionStayFallbackInvoked = true;
}
private void OnCollisionExit(GameObject other)
{
CollisionExitCount++;
LastCollisionOtherName = other != null ? other.name : string.Empty;
}
private void OnTriggerEnter(GameObject other)
{
TriggerEnterCount++;
LastTriggerOtherName = other != null ? other.name : string.Empty;
}
private void OnTriggerStay()
{
TriggerStayCount++;
TriggerStayFallbackInvoked = true;
}
private void OnTriggerExit(GameObject other)
{
TriggerExitCount++;
LastTriggerOtherName = other != null ? other.name : string.Empty;
}
}
}