Drone Enemy Particle Effect Bug


Author: Austin Anderson

Date: 1/11/23


Problem:

The problem this week came with the drone enemy's laser particle effect. It would play correctly when attacking the turret, but it would continue to play after it had killed the enemy turret and was moving on to other targets. The sound of the laser would also continue to play, but this had an easier solution. This sounds like an easy task to fix but I ran into a few other issues while trying to stop the particle effect. First off, I could not check to see if the turret was dead because it would throw an error if the turret was dead. Also, when I would turn the particle effect off, it would get turned back on somewhere else. Finally, figuring out exactly where to turn on and off the particle effect proved to be more complicated than one would think.


Solution: 

I ended up realizing that I could check if the turret was valid, if it was then I could check if its health was <= 0. I realized this would work because it takes a few frames for the turrets to die, therefore I have time to check the health before it is dead. I also stop the laser particle effect if the turret is no longer valid so it turns the particle effect off either way.


Next, I had to figure out why the laser was getting turned back on. Turns out this was happening because it took a few frames for the turret to die. Since the turret was still alive, the attack function kept getting called, turning the laser back on. This issue was also solved in the above photo where I stop the laser if the turret's health is <= 0.  

I created a new behavior tree task to turn off the drone laser if its target was further than it's shoot distance, but placing it was tricky. I tried placing it in a few different places before I found the right spot for it, ensuring that it works as intended.


Get Cyber Siege

Leave a comment

Log in with itch.io to leave a comment.