- Home /
No Negitive input values when asking from another script?
This is just weird... but maybe I am missing something. From another scripts OnTriggerStay I call this function in my Player script:
function pipedir(d:Vector3):boolean{
var ok:boolean=false;
if (d.y!=0){
print(LastInput.y); //This is always a positive number???
if (LastInput.y>0){LastInput.y=1;}
if (LastInput.y<0){LastInput.y=-1;}
if (d.y==-1 & ducked){ok=true;} //ducked is always false? i don't get it?
if (d.y==LastInput.y){ok=true;}
}
if (LastInput.x!=0){
//but the horizontal side for some reason works in the negative?
if (LastInput.x>0){LastInput.x=1;}
if (LastInput.x<0){LastInput.x=-1;}
if (d.x==LastInput.x){ok=true;}
}
if (inapipe){ok=false;}
return ok;
}
The FixedUpdate looks like this:
function FixedUpdate(){
//Bla Bla Bla Movement Code
LastInput.x = Input.GetAxis(horz);
LastInput.y = Input.GetAxis(vert);
print(LastInput.y); //Shows negative values just fine :(
}
So to recap, Inside fixed update, the values are fine.. calling from outside the script shows ducked as false, and vertical input as always 0-1.
Am I just misunderstanding something?
Answer by DaveA · Nov 09, 2011 at 10:51 PM
Are you sure you want bit-wise AND: d.y==-1 & ducked and not &&? Did you declare LastInput outside the functions? Otherwise they'll just be (separate) local vars.
Answer by Aion · Nov 10, 2011 at 12:18 AM
Gah, I feel stupid... the characters collider changed shape when it ducked and moved out of the trigger... facepalm
I knew it was something simple, just couldn't see it.
Your answer

Follow this Question
Related Questions
Check for collisions with script outside of object with collider 0 Answers
How to do combos? 1 Answer
Inventory Add Item Textures Don't Show? 1 Answer
Radar script help 2 Answers
Ball movement script 3 Answers