Einheit Explosionskraft hinzufügen
public void ApplyExplosionForce()
{
float explosionForce = 50.0f;
float affectedRadius = 15.0f;
Collider[] colliders = Physics.OverlapSphere(transform.position, affectedRadius);
foreach (Collider affectedObjects in colliders)
{
if (affectedObjects.TryGetComponent(out Rigidbody rigidbody))
rigidbody.AddExplosionForce(explosionForce, transform.position, affectedRadius, 1.0f, ForceMode.Impulse);
}
}
Programming Doggo