feat(physics): dispatch PhysX simulation events to scene scripts

This commit is contained in:
2026-04-15 13:36:39 +08:00
parent 077786e4c7
commit 51aea47c83
20 changed files with 955 additions and 7 deletions

View 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;
}
}
}