Rather than using a Physics2D circle to decide which GameObjects are to be affected by the explosion, another game situation might be to apply an explosion force to all the objects of a particular tag. In this case, you would replace the explodedCircle scripted component of the explosion GameObject with an instance of the following script class, setting the tagName string to the desired tag in the Inspector window:
using UnityEngine;
public class ExplodeTagged : MonoBehaviour {
public string tagName = "Bug";
public float force = 800f;
public float radius = 3f;
private GameObject[] _gameObjects;
private void Awake(){
_gameObjects = GameObject.FindGameObjectsWithTag(tagName);
}
void Update(){
if (Input.GetKeyUp(KeyCode.Space))
{
Explode();
}
}
private void Explode(){
foreach(var gameObject in _gameObjects){
Rigidbody2D rigidbody2D = gameObject.GetComponent<Rigidbody2D...