- Home /
 
               Question by 
               Blueknight1758 · Aug 12, 2013 at 05:02 PM · 
                gameobjectkey pressed  
              
 
              How to not render gameobject unless key pressed?
Im trying to hide a specific game object (as in not render it) unless I press a certain key.
So far I have this.
 function Update(){
 
     var ShowObject = Input.GetAxis("ShowObject");
 
 if(ShowObject=1)//"Show" key pressed
         /*Render Object, I don't know what to put here*/;
what code can I insert to make this work?
               Comment
              
 
               
               var showObject : boolean;
 
 function Update()
 {
     if(showObject)
         GetComponent($$anonymous$$eshRenderer).enabled = true;
     else
         GetComponent($$anonymous$$eshRenderer.enabled = false;
 }
 
               Best Answer 
              
 
              Answer by Joyrider · Aug 12, 2013 at 05:13 PM
If the script is on the object you could so something like this:
 if(showObject == 1)
 {
    renderer.enabled = true
 }
 else
 {
    renderer.enabled = false
 }
btw, try and use camelCase for variables (start variables with a lowercase, keep capitals for Classes), it's a common convention.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                