I decided to try something else for the raycast mechanic. Instead of the code that I originally had, I changed it to a fairly small function, and a couple lines that calls the function when the mouse is clicked.
It seems to work so far.
Now, no one should be able to swing a sword a dozen times a second, so I needed to add a delay. I used the same technique I used with the weapon switching, using IEnumerator and coroutines.
Now the player can only attack once per second. Obviously this is a bit fast for a bow, but it'll have to do for now.
Next class I'll add a variable for the attack delay that will change based on which weapon you're using. So the bow (I'm thinking of making it a crossbow now) will have a longer attack delay than the sword, which is supposed to simulate reloading the crossbow.
No comments:
Post a Comment