I have an object that should be "falling" on the screen several times, and this works.
What I am trying to do is to have a variable named x receive 1 more each time this object passes the screen. When x receives another 5, I want another variable called and receive minus 1.
For this I declare both variables and assign a value to them: x = 0 and y = 5.
PROBLEM:
x should receive 1 more when the object passes through the screen, and this happens, but only once. When the object first passes through the screen, x receives 1 more, but after that, x to # 1 and receives nothing else.
Foryandminus1,xmustreceive5,soIthinkthat'swhyydoesnotchangethevalue,sincexisnomorethan1.
Noerrormessagesappearduringgameplay.
Whydoesnotthevalueofthevariablexchange?
CODE:
privateintx,y;voidStart(){x=0;y=5;}voidOnBecameInvisible(){//quandooobjetopassarpelatelax+=1;Debug.Log("Valor de x: " + x);
if ((x % 5) == 0)
{
// sempre que x receber mais 5
y -= 1;
Debug.Log("Valor de y: " + y);
}
}
Note: I did not put all the code because the rest of it is about the speed the object will drop, position and stuff like.