feat(physics): dispatch PhysX simulation events to scene scripts
This commit is contained in:
54
managed/GameScripts/PhysicsEventProbe.cs
Normal file
54
managed/GameScripts/PhysicsEventProbe.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user