• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
-1
Question by paddybudz · Apr 18, 2021 at 12:22 AM · game

help,Deleting specific Game Objects that has been instantiated

hi i am new to coding currently trying to make a game where rooms spawn in random configurations with multiple paths but i have run into a problem where the buildings can spawn on top of each other.i have added a trigger at the end of each room to delete the room once you leave it. only problem is it wont delete the other paths that get created and any new rooms that spawn have the chance of spawning over the top of them what would be the best way of solving this problem. is there a way to delete these rooms? i am using Instantiate to spawn these rooms :)alt text

,hi i am new to coding currently trying to make a game where rooms spawn in random configurations with multiple paths but i have run into a problem where the buildings can spawn on top of each other.i have added a trigger at the end of each room to delete the room once you leave it. only problem is it wont delete the other paths that get created and any new rooms that spawn have the chance of spawning over the top of them what would be the best way of solving this problem. is there a way to delete these rooms? i am using Instantiate to spawn these rooms :)

gamehelp2.jpg (276.4 kB)
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image aardappel156 · Apr 19, 2021 at 01:59 PM 1
Share

Greetings!

Welcome to program$$anonymous$$g. These problems can be annoying but definitely fixable. I would love to help you but I am missing some information. Could you send us your code that has to do with deleting and spawning objects? Maybe better if you can post your project on something like github

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by skagontale · Apr 19, 2021 at 02:42 PM

if the object that needs be deleted has a script then when you want the object to be destroyed, inside of its script do: Destroy(gameObject);

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image paddybudz · Apr 25, 2021 at 06:36 AM 0
Share

thanks for the reply skagontale :D i have tried using the Destroy(GameObject) that does work on the Object the script is attached to however i have multiple paths that are instantiated separately i am not sure how to reference these in a script to have them be destroyed as well i have tried using tags but that doesn't seem to work using System.Collections; using System.Collections.Generic; using UnityEngine;

public class extra6 : MonoBehaviour { public float remover;

 void Update () {
     if (remover == 1) {
         DestroyWithTag ("hall1");
         DestroyWithTag ("hall2");
         DestroyWithTag ("hall3");
         DestroyWithTag ("hall4");
         DestroyWithTag ("hall5");
     }
 }
 
 void DestroyWithTag (string destroyTag) {
     GameObject[] destroyObject;
     destroyObject = GameObject.FindGameObjectsWithTag(destroyTag);
     foreach (GameObject oneObject in destroyObject)
         Destroy (oneObject);
     }
 }

it comes up with tag not defined so it wont run the script would you have any idea? :D

avatar image paddybudz · Apr 25, 2021 at 07:06 AM 0
Share

oh so i fixed it the turns out the tags i had in the unity engine had a space in them so it was a easy fix just had add spaces in too the script and it works :D

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

143 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

getting udp package info inside unity (GlovePIE) 0 Answers

main screen game 2 Answers

problem with Raygun 1 Answer

Why are my assets not showing up in the Scene panel? 2 Answers

Do we have 3d online game for android developing in unity3d now? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges