canShoot boolean issue

I have come across an issue whereby the weapons occasionally stop firing.

I’ve done a little digging and found that when I switch away from a weapon before the wait time between shots has elapsed, this appears to immediately stop the coroutine, and ultimately prevents the canShoot boolean from being changed back to true. This effectively disables the weapon until the scene is loaded again.

I have temporarily added an OnEnable method to set the canShoot boolean to true when each weapon is enabled. This stops the weapons from becoming unusable, but then introduces another issue where the user can bypass the wait time between shots by quickly switching weapons and switching back.

Has anyone else come across this or is this just me? Also, if anyone came across it, did anyone find a solution?

Hi Chris,

Admittedly, this is the first time I hear about this problem. I briefly checked Rick’s script, and, just like you, he set canShoot to true in the OnEnable method. If he hasn’t done that in the current lecture yet, he’ll very likely do that in one of the following videos.

Did your solution fix the problem for you?


See also:

Hi Nina,

Thanks for the reply, maybe Rick has already addressed this but I’ve missed it (sometimes I have the kids around when I’m listening to the lectures and it’s easy to miss something!) I probably also should have checked the github code before posting!

I’ll keep the change in for now, as although it opens up a potential exploit, it solves the more important issue of having the guns break mid-game.

Thanks again for the reply.

Edit: I’ve just started the next lecture and Rick addresses it in the first few minutes!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms