Lasers stay on when I collide with something

Thank you for your screenshots. Now I know what you mean, and I agree that this behaviour does not make any sense.

The problem is simple: The emission module gets enabled when the “fire” key was pressed. And if the player gets destroyed, the PlayerController gets disabled. The else-block in ProcessFiring will not get executed anymore.

An equally simple solution would be to have a SetLasersInactive method in the CollisionHandler method. A bunch of components get disabled there, just the lasers are missing.

If you want to challenge yourself, you could create a more elegant solution than copying and pasting the SetLasersActive method. You could outsource the shooting feature to a new class. Then you could make the CollisionHandler call a method in that new object to disable the lasers and to disable the component.

Maybe you’ll come up with an even better idea. :slight_smile:


See also: