Today I fixed the bullets as the speed variable was being defined incorrectly and I then implemented enemy death, I first tried to use a splice in the array to delete the enemy when this didn’t work I added an active state and had the enemy update only when it was active but this has lead to another issue with the enemies collider staying back when the enemy dies, so far I have tried to set the collider to a trigger once the enemy dies so that objects can move past the inactive enemy. This has worked for the enemies but the player still bumps into these inactive objects.
Today I fixed the enemies having active colliders after death and also made it so that the dead enemies respawn, I did this by changing the parameters for the enemy check where before it would check that the array length was below the max enemies (10) now it just checks that the array contains null or inactive enemies. As for the collider issue I’ve fixed it by adding active states to every object and having the collider make sure that the objects are active before performing the functions. I have also made the bullets become inactive on enemy hit, this is so that the enemies require more than 1 hit to defeat and so that the bullets don’t pierce through every enemy. I accomplished this by having the collider check the tags of the objects and making the bullet inactive. Currently the bullet has minor collision, this can lead to the player getting pushed or sometimes stopped for a moment by the bullet, if the player fires the bullet to their left then the bullet pushes them right for a moment after it spawns
A little later I created a system to limit the framerate based on code from JsFiddle(Http://jsfiddlenet/m1erickson/CtsY3/). I used this because many issues were arising from seconds passing to fast and movement issues, now I can set the target framerate easily and base certain variables around that.
References:
Jsfiddle. [no date]. Http://jsfiddlenet/m1erickson/CtsY3/. [Online]. [9 November 2020]. Available from: http://jsfiddle.net/m1erickson/CtsY3/