How to keep a variable from changing?
I'm not sure how to word this question so I will use my code to help. What I am trying to do is get a position of an object and while that object is in that position, I want to turn a boolean to true. However, I also want to translate this object so that it moves but if it moves, the boolean will turn to false since it isnt in the correct position. Can anyone help me with this?
Here is the code:
var topRight : boolean = false;
if((transform.position.x == 7.5) && (transform.position.y == 7.5)){
topRight = true;
transform.Translate(0,1,0);
}
Answer by Wolfshadow · Aug 29, 2015 at 01:58 AM
What do you mean? Is this not your full code? Just keep topright not set. Sorry if I am missing something.
nah this isnt my full code, and i tried to set top right to nothing but it still didnt work :(
Answer by ransomink · Aug 29, 2015 at 02:58 AM
I seem a bit confused. topRight will only turn to false if you set it to false after it moves from the correct position.
Once you set it to true, it stays true until you set it to false again. So my question is where in your script does it get set to false again?
Your answer
Follow this Question
Related Questions
[Help] Getting variable based on string value. 2 Answers
Why doesn't the collider work? 1 Answer