I have a variable called attacking, which starts as false. When you press fire1, if attacking == false, attacking = true and it begins the attack animation. When the animation is over, it sets back to false, making the character able to attack again.
Now, whenever i make ANY changes to ANY script or anything in the inspector, upon testing the game, attack is set to true, making it impossible to attack. I stop the game…test it again and everything works as it should. I can run the game a hundred more times, and it starts as it should. But if I even add something that is commented out and non-functional to a script, or arbitrarily change a totally unrelated variable value, that firt time I run the game again, attacking is strangely set to true.
Anyone else ever experience anything like this? I can get around it by setting up a timer at the beginning of the game for a half a second or so and having attack equal false when the time goes off…but I’d rather try to remedy the problem!
the variable is declared → var attacking = false; Also, jumping = false; and shooting = false;. However, attacking is the only one i have a problem with. And yes, all three of them are private variables.
I have already tried setting it to false in both the start and awake function…still, the same thing happens.
Like I said, its a head scratcher. I’ve gone over and over and over it to the point where i’ve commented out entire sections of code just to see if I can isolate the problem, so far I can’t. Its also strange that jumping and shooting variables, which are also booleans and have the same effect on controllability of my player do not have the same problem.
I’ll keep chipping away and see if I can figure out a solution. Was mostly just curious to see if anyone has had anything like this happen before, what caused it. Thank you for the replies!
Strangely enough, that might have been it. I thought about that while trying to work out the solution, but discounted it… logically it didn’t make sense to me that it would only happen the first time back from updating a script or something in the inspector. Hm. But I did remove mouse input controls and so far it seems to have fixed the problem, thanks!