Collision Detection and Events
public class PlayerCharacter : Character
{
protected override void OnCollided(ref CollisionResult collisionResult)
{
// Call base method implementation
base.OnCollided(ref collisionResult);
// Add your code here...
Debug.Log($"Collided with {collisionResult.collider.name}");
}
}public class PlayerController : MonoBehaviour
{
// The controlled Character
private Character _character;
protected void OnCollided(ref CollisionResult collisionResult)
{
Debug.Log($"Collided with {collisionResult.collider.name}");
}
private void OnEnable()
{
// Subscribe to Character events
_character.Collided += OnCollided;
}
private void OnDisable()
{
// Un-subscribe from Character events
_character.Collided -= OnCollided;
}
}Last updated