- Home /
If statement not working!?
Heres my code i made sure that SpaceCoreInArea is 1 and yet it does not say "work" when i jump!
 #pragma strict
 
 function Start () {
 
 }
 
 function Update () {
 
 if(PlayerInArea.SpaceCoreInArea == 1 && Input.GetKeyUp (KeyCode.Space)){
 
 Debug.Log("Works");
 
 
 
 }
 }
Answer by tanoshimi · Sep 29, 2013 at 08:59 PM
What is PlayerInArea.SpaceCoreInArea, and where is it defined? Are you trying to access a script called SpaceCoreInArea attached to a GameObject called PlayerInArea? Or a variable called SpaceCoreInArea in a script called PlayerInArea? Or is this a custom object that you've created somewhere?
I suggest you read http://docs.unity3d.com/Documentation/Manual/ControllingGameObjectsComponents.html because it sounds a lot like you're not sure how to access components via script.
the space core code is working i tested it on its own but when i added the jump code it no longer works! so yeah its not the space core!
But if you just have the jump code, that works, right?
 function Update () {
   if(Input.Get$$anonymous$$eyUp($$anonymous$$eyCode.Space)){
     Debug.Log("Works");
   }
 }
Yeah! I tryied that and it worked i tryied the other code by itself and it worked! i just dont know how to fix it :(
Well, there's gotta be some other script running somewhere that's interfering then.
... ur i just looked over the space core code and in the update function there was SpaceCoreInArea = 0; ... i'm such a derp
Your answer
 
 
             Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Int and Javascript help 2 Answers
Boxcollider 2D Destroyed 2 Answers
Unexpected char : 0x0 2 Answers
Another Null Reference Exception 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                