-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresetEnemies.cs
More file actions
27 lines (22 loc) · 824 Bytes
/
resetEnemies.cs
File metadata and controls
27 lines (22 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using UnityEngine;
public class resetEnemies : MonoBehaviour
{
[SerializeField] private GameObject enemies;
//respwans all childs under parent object
public void RespawnEnemies(GameObject parentObject)
{
// Loop through all children of the parent object
for (int i = 0; i < parentObject.transform.childCount; i++)
{
GameObject child = parentObject.transform.GetChild(i).gameObject;
// Activate the enemy
child.SetActive(true);
// Get the enemyAllScript component from the child and reset health
enemyAllScript enemyScript = child.GetComponent<enemyAllScript>();
if (enemyScript != null)
{
enemyScript.RespawnEnemy(); // Reset health of the enemy
}
}
}
}