|
|
|
|
|
|
|
|
|
|
public class GameController : MonoBehaviour |
|
|
|
{ |
|
|
|
// public List<
|
|
|
|
public List<Rigidbody> AllRBsList = new List<Rigidbody>(); |
|
|
|
|
|
|
|
public float ExplosionForce = 100; |
|
|
|
public float ExplosionUpwardsModifier = 1; |
|
|
|
public float ExplosionRadius = 10; |
|
|
|
public ForceMode ExplosionForceMode; |
|
|
|
|
|
|
|
public bool triggerExplosion; |
|
|
|
void Start() |
|
|
|
void Awake() |
|
|
|
Rigidbody[] rbs = Resources.FindObjectsOfTypeAll<Rigidbody>(); |
|
|
|
foreach (var rb in rbs) |
|
|
|
{ |
|
|
|
if (!rb.transform.CompareTag("projectile")) |
|
|
|
{ |
|
|
|
AllRBsList.Add(rb); |
|
|
|
} |
|
|
|
} |
|
|
|
if (triggerExplosion) |
|
|
|
{ |
|
|
|
triggerExplosion = false; |
|
|
|
AddExplosiveForcesToAllRB(transform.position); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void AddExplosiveForcesToAllRB(Vector3 pos) |
|
|
|
{ |
|
|
|
foreach (var rb in AllRBsList) |
|
|
|
{ |
|
|
|
rb.AddExplosionForce(ExplosionForce, pos, ExplosionRadius, ExplosionUpwardsModifier, ExplosionForceMode); |
|
|
|
} |
|
|
|
} |
|
|
|
} |