changed variables in script not being saved
I have my code set up to change the value of my Vector3Int's x value and it seems to change it, but that change is immediately thrown away, and I can't think of any reason why it's doing it. I've also tried making it variable equal to a new Vector3Int but that doesn't work either.
What the Debug.Log brings up is. 1st one - original start.x value. 2nd one - new value. 3rd one - the original value.
As far as I can tell the 3rd one should be returning the new value, but it's not being saved for some reason.
void EditLR(bool l, bool r){
if(!l){
if(direction == 0){
Debug.Log(start.x);
start.x--;
Debug.Log(start.x);
}
else if(direction == 1){
start.y++;
}
else if(direction == 2){
start.x++;
}
else if(direction == 3){
start.y--;
}
}
if(!r){
if(direction == 0){
start.x++;
}
else if(direction == 1){
start.y--;
}
else if(direction == 2){
start.x--;
}
else if(direction == 3){
start.y++;
}
}
}
public Vector3Int[] GetTiles(){
Debug.Log('s');
EditLR(L,R);
Debug.Log(start.x);
Debug.Log('e');
Answer by nitrogames79 · Nov 18, 2020 at 09:00 PM
I've just realized that when the bool for r is false, it edits start instead of another variable I wanted to change.
Your answer
![](https://koobas.hobune.stream/wayback/20220613020004im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How would I make a variable equal a variable but only its past value? 1 Answer
Help with variables 1 Answer
Is there a way to assign variables before Awake() is triggered 3 Answers
Why wont my slider change my variable,Why wont my variable update with slider 1 Answer
Change of static variable 1 Answer