In this blog post I’ll be working on adding more to our attack feature as well as adding some code for our enemies
So lets get started. The first thing I we will have to do is now add a direction for our sword to swing. These directions will correspond to those of the actual player when he swings the sword.
Along with the above code for direction we will be adding the code below which will stop our sword.
Now that we have our direction our sword should swing in the direction we are facing. (if you are having troubles feel free to email me I will do my best to help).
Since our sword can now swing in an actual direction as opposed to randomly we can finally add some enemies to test it against. My first enemy will be an Octorock. Add it into the layout and add this highlighted code.
This will allow us to deal damage to the Octorock. And we will also be able to add a damage variable to all of our player weapons with some easy coding.
But for now all we need to do is set our Octorock health to ten and then we can test out our sword. As long as your sword works that’s all for this blog post I hope you enjoyed and I’ll have another one coming out tomorrow
Be sure to check out my YT channel link: https://www.youtube.com/channel/UCrlNUqQVBxLIbdltHQBdcYg?view_as=subscriber Here I upload daily videos or live streams that are about Minecraft be sure to hop in and check it out!