Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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
0
Question by rebelarcher · Jul 26, 2018 at 11:06 AM · destroyspawningtagscolorstagging

How can i destroy spawned objects according a indicator?

Hi Guys. I have 7 Spawned objects and i have a random changed indicator with every played game. This indicator are have 7 Color/Tag. And 7 spawned objs. are have 7 tag one by one. I want, if this objects tag, are equal tag of indicator. i want destroy spawned objs one by one with mouse click. i tried many way but i can not do this. Please help me. And Sorry for my bad eng.

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by rebelarcher · Jul 26, 2018 at 11:12 AM

i hope this img helps you


114573-adsız.png (103.4 kB)
Comment
Add comment · 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
0

Answer by AdityaViaxor · Jul 26, 2018 at 12:59 PM

Simple, make a script which will be on GameManager(Empty gameobject) and Get Reference of Indicator and from that reference get tag/color of indicator then in other remaining cubes(object) have their own script now in cube script get the tag of indicator from GameManager script below is demo., 1) Create GameManager empty game object attach script Color_Colletctor (or any name)

{

public class Color_Collector: Monobehavior

string colorTag

public GameOBject Indicator;

{

  Update()
   {
         colorTag =  Indicator.Tag;
  }

   

}

}


2) Script on other 6 cube (make one script and attach to all) Cube.cs

{

   public class Cube: Monobehaviour
   {

            public Gameobject GameManagrer;

             void Update()


            {
                if(input.GetMouseButtonDown(0))
                {  
                       if(GameManager.color==this.gameobject.color)
                       {
                               Destroy (this.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 rebelarcher · Jul 27, 2018 at 05:12 PM 0
Share

i using 7 objects in indicator. Those are random spawning. And 7 different objects are spawning. they are have same tag. Just we can use the tag ?

avatar image AdityaViaxor rebelarcher · Jul 28, 2018 at 06:21 AM 0
Share

buddy no need to use 7 different object use one object just change color of that and tag it would be more efficient way. when you spawn indicator just change color on start or onEnable function. and set tag programmatically make "string tag" variable and when cube spawn set random color and set the same name as a tag

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.

Follow this Question

Answers Answers and Comments

94 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

Related Questions

Destroying Multiple Objects with Tags 1 Answer

Destroy Clone when colliding with 2d box collider 0 Answers

Raycast isn't working when with tag 2 Answers

Drag/drop potentially unlimited generated "creep" objects, but one at a time 0 Answers

Destroying GameController Respawns? 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