What I Learned This Month
-How to add a simple enemy AI script to an object
-How to add delays using IEnumerator
-How to use Audacity to edit sound files
-How to add sounds to the game that can be activated by the script
I didn't learn that much this month, since most of the month was me using what I already knew, and applying it in different ways.
What I Accomplished
This month I Added an enemy AI script, weapon sounds for the player, and added a statistics script to control the enemy's health, speed, and damage dealt.
Next month, I plan to add in the damage system. I also plan to start planning a storyline for the game.
Wednesday, May 31, 2017
Day 53: Audio-Only Game: Day 28
Well, turns out I already had the script that will work. I forgot I had made it a function. All i need now is to add a couple lines that changes the enemy's health.
..Which, of course, I don't know how to do. So now I need to find a tutorial for that, hopefully next class.
..Which, of course, I don't know how to do. So now I need to find a tutorial for that, hopefully next class.
Monday, May 29, 2017
Day 52: Audio-Only Game: Day 27
Most of the class I spent searching for a tutorial that told me how to make a raycast on mouse click only, however all the tutorials I found didn't help. Nearer to the end of the class, I decided to at least make the statistics script for the enemies.
It's fairly simple. All I need to do is change the values of the variables in the unity editor depending on what the enemy is.
Next class, continue to search for a tutorial that has what I need.
Friday, May 26, 2017
Day 51: Audio-Only Game: Day 26
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.
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.
Thursday, May 25, 2017
Day 50: Audio-Only Game: Day 25
When I opened up the game, I saw this:
It was a bit concerning, but it didn't seem like anything was broken...yet.
I decided to scrap the crossbow sound again, but this time, I'm going to build the script piece by piece, and test each part. That way, I'll be able to find what's wrong with it.
First of all, I starting with a simple script. All this does is, if the mouse button is clicked, and distance = 100, the crossbow shoot sound will be played.
It does exactly as expected, and plays the sound properly.
I then noticed that whenever I clicked, it created a new audiosource, and I had nothing in place to delete them.
To fix this, I added a "destroy" script that destroys the audiosource after 1 second.
Now to add the delay. This is tough, because I need it to work with the reload script as well. I used the AttackDelay function. I also used one of the booleans to prevent the crossbow from being shot during the delay.
Next class, I will add on to the script, and probably start on the reload sound script.
It was a bit concerning, but it didn't seem like anything was broken...yet.
I decided to scrap the crossbow sound again, but this time, I'm going to build the script piece by piece, and test each part. That way, I'll be able to find what's wrong with it.
First of all, I starting with a simple script. All this does is, if the mouse button is clicked, and distance = 100, the crossbow shoot sound will be played.
It does exactly as expected, and plays the sound properly.
I then noticed that whenever I clicked, it created a new audiosource, and I had nothing in place to delete them.
To fix this, I added a "destroy" script that destroys the audiosource after 1 second.
Now to add the delay. This is tough, because I need it to work with the reload script as well. I used the AttackDelay function. I also used one of the booleans to prevent the crossbow from being shot during the delay.
Next class, I will add on to the script, and probably start on the reload sound script.
Wednesday, May 24, 2017
Day 49: Audio-only Game: Day 24
To start with, I deleted pretty much all the sound code for attacking.
Next, I copy/pasted the if statement. One will be for the crossbow shooting, one for reloading, and one for the sword swing.
This is the first of the three if statements, the one that controls the crossbow shooting:
The second one, which controls the reloading mechanic:
And finally, the sword swish sound:
I added to all of them a condition that the Distance variable must equal 100 for the crossbow sounds, and 3 for the sword sound.
The sword swish sound works perfectly, but the crossbow sounds aren't working yet.
Next class I will be focusing completely on the crossbow sound until it works.
Next, I copy/pasted the if statement. One will be for the crossbow shooting, one for reloading, and one for the sword swing.
This is the first of the three if statements, the one that controls the crossbow shooting:
The second one, which controls the reloading mechanic:
And finally, the sword swish sound:
I added to all of them a condition that the Distance variable must equal 100 for the crossbow sounds, and 3 for the sword sound.
The sword swish sound works perfectly, but the crossbow sounds aren't working yet.
Next class I will be focusing completely on the crossbow sound until it works.
Tuesday, May 23, 2017
Day 48: Audio-only Game: Day 23
The entire class, all I did was try to get the crossbow sounds work. I scrapped the original crossbow sound script and tried something a bit different, but it still isn't working. The problem is that it seems to skip the "if ((Distance == 100) && (Loaded != false) && (Loading != true));" script (which plays the shooting sound, and go straight to the script that plays the reload sound.
Next class, and probably the class after, I will continue trying to get it to work. I might try to split them into separate "if(input..." scripts, instead of putting if statements inside an if statement.
Thursday, May 18, 2017
Day 47: Audio-only Game: Day 22
Apparently Unity has a huge update, so it'll be a while before I can work on anything.
Once that was over, I still had enough time to add the other sounds. First of all, I added the sounds to the script.
Next, I made yet another delay script. This one will go between the sound of the crossbow shooting, and it reloading.
Once that was over, I still had enough time to add the other sounds. First of all, I added the sounds to the script.
Next, I made yet another delay script. This one will go between the sound of the crossbow shooting, and it reloading.
Wednesday, May 17, 2017
Day 46: Audio-only Game: Day 21
The first sound I added was the "sword unsheath" sound. I already had it assigned to the Unsheath storage variable, so all I needed was to put 3 lines of code in the right place, the one's starting with "this."
The first of the three lines gets the audiosource component that is attached to the player. The second one gets the sound from where it is stored in the variable. The third line plays it through the audiosource recognized by the first line.
I simply repeated this for the CrossbowEquip sound.
Next class I will add the attack and reload sounds.
The first of the three lines gets the audiosource component that is attached to the player. The second one gets the sound from where it is stored in the variable. The third line plays it through the audiosource recognized by the first line.
I simply repeated this for the CrossbowEquip sound.
Next class I will add the attack and reload sounds.
Friday, May 12, 2017
Day 45: Audio-only Game: Day 20
I found a sound file with literally every bow/crossbow/arrow sound from TES 5: Skyrim. All I needed to do was select one part of the file and click "Export selected". I chose to export them as a .wav file.
So now that I have crossbow sound effects, I can add them to my game. I simply imported them as assets, and they're ready to use.
In my Combat script, I added more audioclip 'variables', and assigned the appropriate sound to each.
I tested my script, just to make sure it still works, and it seems there's a problem. The raycasting and equipping mechanic isn't working. NONE of it is working, really. So now I have to go through the entire script to find what's wrong with it.
I've found a fix, but I just don't understand why it stopped working. In the void start function, I added a few lines that sets two of the booleans, and one integer. Apparently, since they weren't set before, the script couldn't use them since there were no values assigned.
Now that I've gotten that sorted out, I can continue with the sound...next class.
So now that I have crossbow sound effects, I can add them to my game. I simply imported them as assets, and they're ready to use.
In my Combat script, I added more audioclip 'variables', and assigned the appropriate sound to each.
I tested my script, just to make sure it still works, and it seems there's a problem. The raycasting and equipping mechanic isn't working. NONE of it is working, really. So now I have to go through the entire script to find what's wrong with it.
I've found a fix, but I just don't understand why it stopped working. In the void start function, I added a few lines that sets two of the booleans, and one integer. Apparently, since they weren't set before, the script couldn't use them since there were no values assigned.
Now that I've gotten that sorted out, I can continue with the sound...next class.
Day 44: Audio-only Game: Day 19
An "audio-only" game would be kind of pointless without sound effects. Most of what I will use I can find on SFX websites (licensing shouldn't be a problem since I'm not getting money from the game). However, I'll need a program to edit the sound files to fit my needs. For that, I decided to use Audacity: A free sound editor.
Now that that's done, I can look for sound effects. I found two "medieval" sound effects packs which includes sounds for swords, bows, and dozens others. Unfortunately, most of the blade-on-blade sounds are just light tapping. There's no real clash. So I probably won't be using many of those sounds.
Luckily, the unity asset store has some free sounds. I found a "woosh" sound that I will probably use for the sword swing.
To be able to play a sound effect using script, I needed to first add these two lines as variables. As seen here, I'm using an "unsheath" sound. Afterwards, I changed UnsheathSound to PlayerSound, since that audio source will be used for more than one sound.
I then inserted a line of code into the script that controls the sword selection, so if the sword is not equipped and "1" is pressed, the sound will play.
Next class I will add more sounds such as the sword swing, sheathing the sword, and the crossbow sounds.
Wednesday, May 10, 2017
Day 43: Audio-only Game: Day 18
I made the integer variable that would define the delay between dealing damage.
Then, in the weapon-switching script, I added lines to change the StrikeDelayInt variable when "1" or "2" is pressed, changing the delay according to the weapon being used.
It wasn't working properly, so I went through the script, and found that two lines were in the wrong order. I fixed it.
Then, to the weapon switching script, I added a condition that CanAttack must be true. That way, the player can't switch back and forth between weapons until the first one is completely usable.
Next class I will try to learn how to add sound effects.
Then, in the weapon-switching script, I added lines to change the StrikeDelayInt variable when "1" or "2" is pressed, changing the delay according to the weapon being used.
It wasn't working properly, so I went through the script, and found that two lines were in the wrong order. I fixed it.
Then, to the weapon switching script, I added a condition that CanAttack must be true. That way, the player can't switch back and forth between weapons until the first one is completely usable.
Next class I will try to learn how to add sound effects.
Monday, May 8, 2017
Day 42: Audio-only Game: Day 17
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.
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.
Subscribe to:
Posts (Atom)