Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 cesarpc1998 · Jun 09, 2020 at 08:56 PM · destroydestroy object

Set destroy order

Hello, I would like to implement something for my game, but I don't know how or where to start. I would like to set a destroy order, a good example of this is that I have a red ball and has a Number 1 that indicates that the player needs to destroy that ball first and so on, and if he/she destroys other balls they lose.

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
Best Answer

Answer by someonethatis · Jun 09, 2020 at 10:03 PM

lest's say you have 3 balls

note I'm typing code on this so don't get mad when it looks weird

you can go

  GameObject  ball1;
   GameObject ball2;
  GameObject ball3
  void Update(){
        if(ball1 != null && ball2 = null)
        {
              // lose
        }
         if(ball1 !=  null && ball3 == null){
              //lose
         }
         if (ball2 != null && ball 3 == null){
              //lose
          }

        // put this at the end
        if(ball1 == null && ball2 == null &&ball3 == null){
                 //win
        }
  }

or

you can use a index like this (this might not work but probably can be modified to work)

   GameObject[] balls = new GameObject[However many balls];
 //you need to go to the inspector and put the balls in order to what you want to destroy first

 void Update()
 {
     foreach (GameObject ball in balls)
     {
         int minisIndex = 0;
         int OminisIndex = 1;
         int index = 0;
         if (OminisIndex <= 1)
         {
             minisIndex = OminisIndex;
             for (int i = 0;i==minisIndex;i+=0) {
                 
                 if (balls[minisIndex] != null && balls[index] == null)
                 {
                     //lose
                 }
                 minisIndex--;
             }
             
             
         }
         index++;
         OminisIndex++;
     }
 }

tell me if this was help full

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 cesarpc1998 · Jun 09, 2020 at 10:56 PM

@someonethatis I have a problem because if I have different levels with different Ball quantities the script won't work

Comment
Add comment · Show 5 · 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 someonethatis · Jun 10, 2020 at 03:47 PM 0
Share

use diffrent scenes

avatar image someonethatis · Jun 10, 2020 at 03:48 PM 0
Share

or even just have another array of arrays

avatar image someonethatis · Jun 10, 2020 at 03:49 PM 0
Share

and did it work for 1 level?

avatar image cesarpc1998 someonethatis · Jun 11, 2020 at 03:42 PM 0
Share

Yes, I did some modification and it works, your answers were helpful!

avatar image someonethatis · Jun 10, 2020 at 03:50 PM 0
Share

Do you think you can fix it just let me know @cesarpc1998

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

134 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

Related Questions

Script doesn't work anymore! 2 Answers

Hi Im just trying to get my projectile to destroy a game object and Im having a hard time figuring it out. Any help is appreciated.c# :) 1 Answer

Destroying a Button when you click it. 1 Answer

How to play a destroy animation? Brick Breaker/Arkanoid. 1 Answer

Does calling Destroy(material) destroy the texture as well? 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