In todays blog post we will be adding a knockback mechanic for our player so that when he is hit by either the enemy bullet or the enemy itself he takes knockback.
To do this we will need a couple key pieces of code that will basically allow this to be a function in our game.
This is the first chunk of code we will need to add. which will basically make it so that our player will not only take knockback when he is hit by enemies he will also lose health.
Next we will need to add this code.
This code will make it so that our player takes knockback from enemies weapons and other attacks as well as damage. This will be our second to last piece of code that will allow our player to take knockback.
But there is one problem the player will infinetly take knockback because of the bullet behavior we gave him so we need to add one final piece of code that will make it so that this does not become a problem.
This code will make it so that our player can only take knockback 35 pixels and then it also makes him invincible so that enemies cannot keep ping ponging him across the map unfairly.
Thanks for reading this blog post I hope you enjoyed. Be sure to check out my Yt channel link: https://www.youtube.com/channel/UCrlNUqQVBxLIbdltHQBdcYg?view_as=subscriber
I post nearly daily streams and videos in fact I will be streaming today at 4pm PST so come to the stream and check it out.
3 thoughts on “Adventure pt.14”
I got what you mean,saved to bookmarks, very nice site. Yovonnda Moise Furie
Hi there, I would like to subscribe for this webpage to obtain latest updates, so where can i do it please help out. Fanni Ian Daye
Keep on writing, great job!
Comments are closed.