I’m curious what methods people use for having classes interact with each other when they collide. For example if a projectile collides with something that can take damage.
I’ve always done something like this:
private void OnCollisionEnter(Collision other) {
var damageable = other.gameObject.GetComponent<IDamageable>();
damageable?.Damage(_damage);
}
It works just fine, but I’d prefer not to use GetComponent. Any more clever solutions?