- Home /
 
               Question by 
               GhostlyFedoras · Jul 17, 2019 at 11:19 AM · 
                c#inputsetactivechild objectparent-child  
              
 
              Enabling/Deactivating objects using keys.
Basically I have this script that I have put below, and the issue is that I can not get the boolean to change nor is the item switching working, I'm not sure what I have done wrong I have this attached to a Empty object as shown in the image below, I am not sure if this is due to it being in an empty object(though it is always active) or if it is because I have done the Input code wrong, Hope someone can help, Thanks
 public class SelectWeapon : MonoBehaviour
 {
     public bool Item1IsOn = true;
     public bool Item2IsOn = false;
 
     void update()
     {
         if (Input.GetKeyDown(KeyCode.Alpha1))
         {
             this.transform.GetChild(InventoryScript.ItemIndex1).gameObject.SetActive(Item1IsOn);
             Item1IsOn = !Item1IsOn;
         }
 
         if (Input.GetKeyDown(KeyCode.Alpha2))
         {
             this.transform.GetChild(InventoryScript.ItemIndex2).gameObject.SetActive(Item2IsOn);
             Item2IsOn = !Item2IsOn;
         }
     }
 }

 
                 
                emptyobjectscript.png 
                (13.5 kB) 
               
 
              
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by Forodin · Jul 17, 2019 at 11:21 PM
You need to capitalize the U in Update :)
That's perfect, Honestly I cannot believe I missed that, I made the script a couple days before I added anything to it as I was working on other issues first and I guess I must have remade the Update function.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                