Does anyone have a solution to this ? When I do the subtraction , it makes a loop that does not stop.
if ((lamp.activeSelf == true)&&(test == true))
{
money = money - 50; // <---- This is the problem
test = false;
}
lamp.activeSelf && test
\$\endgroup\$test
— suggesting that some code elsewhere is resettingtest
to true. Could also be that this is inside a setter formoney
itself (or a method called by that setter) so subtracting from money triggers a recursive call sequence. There'd still need to be something resettingtest
. We'll need to see more code & symptoms to diagnose. \$\endgroup\$