First of all, I added the "loaded" variable to the crossbowshoot script to prevent it from shooting if it has already shot, and hasn't been reloaded.
Then, I added the second block of script for the reloading mechanic/sound.
Finally, I added "&& loading == false" to make sure you can't shoot while the crossbow's loading.
After playing around with the lines that destroy the audiosource after it is used, I finally found the perfect delays. Here is the finished product:
And it works! I also added a line that destroys the audio created for the Equip sounds.
I also noticed that even if I already have the crossbow equipped, for example, I can press 2 again, and it will play the sound again.
I added a requirement to the if statement that basically says "if distance does not equal 100" for the crossbow, and "if distance does not equal 3" for the sword. So basically, If the distance is already the distance of the weapon you're trying to equip, it will not do anything when you try to re-equip it.
That didn't work, so I decided to try the longer, more annoying way. Instead of testing whether it is not a certain distance, I decided to have it test for whether or not it is a specific value. So, if I want to equip the crossbow, it would make sure the value is either 3 or 0, so sword distance, or nothing. I also had it make sure that "loading" is false, so they can't switch while the crossbow is loading.
And that concludes Day 51. Now that the basic weapon sounds are finally finished, I can focus on other things, such as health and damage.
No comments:
Post a Comment