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 /
  • Help Room /
avatar image
0
Question by Arkins_prod_studio · Sep 16, 2016 at 02:14 PM · functionbooleannot workinginputfieldif-else

multi verification

Hi everybody i have problems with a "multi verification" for a school project. you'll not understand all because it's in french and german but i make comment in english for you :)

 #pragma strict
 
 var vie1 : boolean = true; // vie = life
 var v1 : GameObject;        // v for vie (life)
 var d1 : GameObject;       // d for death
 var vie2 : boolean = true;
 var v2 : GameObject;
 var d2 : GameObject;
 var vie3 : boolean = true;
 var v3 : GameObject;
 var d3 : GameObject;
 var vie4 : boolean = true;
 var v4 : GameObject;
 var d4 : GameObject;
 var vie5 : boolean = true;         //you see there's five lifes
 var v5 : GameObject;
 var d5 : GameObject;
 var os : UnityEngine.UI.InputField;              //bone
 var dent : UnityEngine.UI.InputField;          //teeth
 var coeur : UnityEngine.UI.InputField;        //heart
 var estomac : UnityEngine.UI.InputField;   //stomac
 var cerveau : UnityEngine.UI.InputField;    //brain
 var nerf : UnityEngine.UI.InputField;           //nerv
 
 function Start(){        //all lifes are activated
     vie1 = true;
     vie2 = true;
     vie3 = true;
     vie4 = true;
     vie5 = true;
 
 }

 function Update(){                    //i check all frames if life are activated or not
     if(vie1 == true){
         v1.SetActive(true);
         d1.SetActive(false);
     }
     if(vie1 == false){
         v1.SetActive(false);
         d1.SetActive(true);
     }
     if(vie2 == true){
         v2.SetActive(true);
         d2.SetActive(false);
     }
     if(vie2 == false){
         v2.SetActive(false);
         d2.SetActive(true);
     }
     if(vie3 == true){
         v3.SetActive(true);
         d3.SetActive(false);
     }
     if(vie3 == false){
         v3.SetActive(false);
         d3.SetActive(true);
     }
     if(vie4 == true){
         v4.SetActive(true);
         d4.SetActive(false);
     }
     if(vie4 == false){
         v4.SetActive(false);
         d4.SetActive(true);
     }
     if(vie5 == true){
         v5.SetActive(true);
         d5.SetActive(false);
 }
     if(vie5 == false){
         v5.SetActive(false);
         d5.SetActive(true);
     }
 }
 function OnEndEdit() {                        //i check what is written in input field
     if(os.text != "der Knochen"){
         if(vie1 == true){                       // <------ the problem begin here :)
             vie1 = !vie1;
         }else{
             if(vie2 == true){
                 vie2 = !vie2;
             }else{
                 if(vie3 == true){
                     vie3 = !vie3;
                 }else{
                     if(vie4 == true){
                         vie4 = !vie4;
                     }else{
                         if(vie5 == true){
                             vie5 = !vie5;
                         }
                     }
                 }
             }
         }
     }
     if(dent.text != "der Zahn"){
         if(vie1 == true){
             vie1 = !vie1;
         }else{
             if(vie2 == true){
                 vie2 = !vie2;
             }else{
                 if(vie3 == true){
                     vie3 = !vie3;
                 }else{
                     if(vie4 == true){
                         vie4 = !vie4;
                     }else{
                         if(vie5 == true){
                             vie5 = !vie5;
                         }
                     }
                 }
             }
         }
     }
     if(coeur.text != "das Herz"){
         if(vie1 == true){
             vie1 = !vie1;
         }else{
             if(vie2 == true){
                 vie2 = !vie2;
             }else{
                 if(vie3 == true){
                     vie3 = !vie3;
                 }else{
                     if(vie4 == true){
                         vie4 = !vie4;
                     }else{
                         if(vie5 == true){
                             vie5 = !vie5;
                         }
                     }
                 }
             }
         }
     }
     if(estomac.text != "der Magen"){
         if(vie1 == true){
             vie1 = !vie1;
         }else{
             if(vie2 == true){
                 vie2 = !vie2;
             }else{
                 if(vie3 == true){
                     vie3 = !vie3;
                 }else{
                     if(vie4 == true){
                         vie4 = !vie4;
                     }else{
                         if(vie5 == true){
                             vie5 = !vie5;
                         }
                     }
                 }
             }
         }
     }
     if(cerveau.text != "das Gehirn"){
         if(vie1 == true){
             vie1 = !vie1;
         }else{
             if(vie2 == true){
                 vie2 = !vie2;
             }else{
                 if(vie3 == true){
                     vie3 = !vie3;
                 }else{
                     if(vie4 == true){
                         vie4 = !vie4;
                     }else{
                         if(vie5 == true){
                             vie5 = !vie5;
                         }
                     }
                 }
             }
         }
     }
     if(nerf.text != "der Nerv"){
         if(vie1 == true){
             vie1 = !vie1;
         }else{
             if(vie2 == true){
                 vie2 = !vie2;
             }else{
                 if(vie3 == true){
                     vie3 = !vie3;
                 }else{
                     if(vie4 == true){
                         vie4 = !vie4;
                     }else{
                         if(vie5 == true){
                             vie5 = !vie5;
                         }
                     }
                 }
             }
         }
     }
 }

I hope you'll can help me fastly <3 liebe grüssung in german, big kiss in english, gros becs in french! Arkin160

Comment
Add comment · Show 2
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 ScaniX · Sep 16, 2016 at 01:12 PM 1
Share

You're not really saying what the problem is, n'es pas? :)

BTW: You can shorten some things quite a bit to make it easier to read:

  v1.SetActive(vie1);
  d1.SetActive(!vie1);

 if(os.text != "der $$anonymous$$nochen"){
      if (vie1) {                       // <------ the problem begin here :)
          vie1 = false;
      } else if (vie2) {
          vie2 = false;
      }else if (vie3) {
          vie3 = false;
      }else if(vie4){
          vie4 = false;
      }else if (vie5){
          vie5 = false;
      }
  }

You should probably describe in short what this is supposed to do. Without it, this just seems to kill lots of organs when the name is incorrect. ^-^

avatar image Arkins_prod_studio ScaniX · Sep 16, 2016 at 08:41 PM 0
Share

hahaha i really loughs when a read your answer x), thanks for your answer but i made more simply like behind :). about the description, you're right, i must more discribe what all do, but i don't have the time to do this; i don't have time for me, i always work, so i must take shortcuts. thank's agen for your answer :) chiao la biz :) Arkin

1 Reply

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

Answer by Arkins_prod_studio · Sep 16, 2016 at 08:36 PM

I made a system more symple: I created a var something : int; and when the word is false, it's adding 1 like this: if(cerveau.text != "das Gehirn"){ something++; } and in function update: if(something == 1){ vie1 = false; } voila c'est tout (that's all ;) )

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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Why my Screen.fullScreen isn't working? 1 Answer

Mecanim OnAnimatorMove function not being called? 1 Answer

Problem with Button and Functions 0 Answers

Game crashes when function is triggered, 0 Answers

Unity 2017.3.1 timeScale not working ? 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