Today we will be working on adding more code to our enemies including code that allows them to shoot as well as code for our player to take knockback and damage from these hits.
Now we will start with adding code for our enemies shooting.
This first piece of code has a few functions, the first is that it will only trigger once the attack timer is running, next it will spawn its bullet that will automatically begin shooting as it has a bullet behavior and it will then toggle the attack timer so that it is randomized.
With this our Octorock will be able to shoot his bullets. But they will not be able to collide with anything nor will they stop moving. So we will obviously need to add code to fix this.
This wat if our Octorock collides with anything on our layout that is a solid like our player we will be able to destroy/stop our bullet.
Finally for this post we need to add some features that allow our player to take knockback when he is hit.
So with this our player will take knockback from all of our enmies projectiles and our enemies will now shoot at our player at random intervals.
Thanks for reading my blog post if you enjoyed consider checking out my youtube channel where I have almost daily livestreams and videos. Link:https://www.youtube.com/channel/UCrlNUqQVBxLIbdltHQBdcYg?view_as=subscriber