unity destroy all objects with tag

GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy");   
foreach(GameObject enemy in enemies)  
{
	GameObject.Destroy(enemy);
}

4
3
Awgiedawgie 440215 points

                                    GameObject[] taggedObjects = GameObject.FindGameObjectsWithTag("Tag");   
foreach (GameObject object in taggedObjects) {
	Destroy(object);
}

4 (3 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
how to destroy gameobject with tag in unity unity destroy objects with tag unity destroy gameobject tag how to destroy object with tag unity destroy gameobject tag unity destroy with tag how to destroy an object using tag n unity destroy tag unity unity destroy all game objects with tag how to destroy an object by tag in unity unity destroy game object with tag unity find game objects with tag and destroy all unity remove all objects with tag unity delete all objects with tag destroy all gameobjects with tag unity unity destroy gameobject with tag destroy object with tag unity how to destroy all gameobjects with the same tag in script in unity destroy gameobject with tag unity unity desoy all with gametag how to destroy all objects wirh the same tag destroy gameobject with tag destroy object by tag unity destroy all objects with tag unity Unity destroy all enemies with different tags Unity destroy all enemies with tag unity search for objects in the scene with a tag and destroy them unity destroy all gameobjects with tag unity remove all gameobject with tag destory every gameobject with tag how to destroy game objects with a certain tag Untiy destroy all objects will tag destroy everything with tag unity destroy all game objects with tag unity destroy all objects with tag destroy all objects with tag unity destroy object with tag unity delete all game objects with tag destroy get component by tag unity destroy objects with tags destroy objects with tag unity unity how to delete all object with certain tag from the scnee
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source