Friday, June 16, 2017

Day 62: End of Year Post

Well, I made it. Sixty-nine posts total, including monthly posts, and the odd "side-post". I've probably learned more in this course that I will use, than I did in my chemistry class.

I've learned the basics of Unity such as camera controls, adding/manipulating objects, and using the child/parent system. Then I learned some more complicated stuff such as colliders, and using them in a script, as shown in my first (Roll-a-Ball) project. Later, I learned some more complicated scripting that included different variables such as strings and bool, and also included raycasting, and using raycasts to access variables in another game object. Finally, I took all that I learned (along with a dozen help pages and tutorials) and used it to start making a game (Audio-Only). One of the big things I learned from making it was how to use sound in Unity. I could probably compact it down by making it a function, but I decided to keep it expanded just so I know what's going on.

Now, next year there will probably be more people taking the independent course. So here's some advice for them, if they decide to learn Unity.

1) Start small.
Many people may be tempted to jump right in to a big project. DO NOT DO THIS. You will lose interest extremely fast. 90% of your time will be spent looking up tutorials and asking questions on the forums. Do the official Unity tutorials before you take on a project of any size.

2) Learn how the code works.
While doing the tutorials, don't just type it in without figuring out how it works. That's not the point of learning. If the tutorial doesn't explain it in enough detail, do some experimenting. Find out what works.

3) Use the Asset Store
Most of the assets cost money, but there are many free objects and tools that are decent quality. If it's a script, learn how it works.

Day 61: Audio-Only Game: Day 36

(Continuing from last class)

[Henrik] You're quite the figure here, friend.

[Player] It seems I am...

[Guest] It is him!

[Henrik] So, now that you're here, I can introduce you to some more-

(Rumbling sound. Guests stop talking)

[Henrik] (hesitant)...friends of mine...

[player] What was that?

[guide] I do not know sir.

(Sound of wall exploding, crumbling. Guests scream, run.)

[Henrik] (angry) What the devil is this?!

[player] What is happening?

[guide] Th...the dead are walking!

[Henrik] Necromancer! Guard. Get the guests to safety. I shall hold of the dead.

[player] as will I.

[Henrik] But you're blind!

[player] My hearing is as good as ever. Hand me a sword!

(Player can now equip and use a sword. Fighting ensues.)

(After the player has killed most of the enemies...)

[Henrik] You were not lying, friend! Though blind, you can still wield a blade!

[player] Would I lie to you?

[Henrik] Of course you wou-

(Sound of roof collapsing. Henrik and the guide yell. Then silence.)

[player] Henrik!

[Necromancer] How touching.

[player] You! You shall pay for what has taken place here!

[Necromancer] You are wrong. We shall rule eternal.

(Necromancer leaves and a few more of his minions attack. Once they're dead...)

[guard] Sir! We must leave. The manor is collapsing!

[player] My guide...and Henrik...

[guard] We can not save them. Come with me.

(The player follows the guard, who tells him to hurry up if the player hesitates too long.)



Tomorrow, I will do my last post, which will include advice for people planning to learn Unity in Info Tech.

Wednesday, June 14, 2017

Day 60: Audio-Only Game: Day 35

Now that I've gotten the basic outline for the game done, I can now do a much more detailed "script" for the game, sort of like a movie script. So, here we go...

The game starts with a black screen (the whole game will be like that), and silent. The sound of two horses gradually fades in. One horse can be heard to the left of the player, and one in the same spot as the player, to give the impression that the character is riding it. On the second horse is the person guiding the player.

[guide] Have you ever met Jarl Henrik before?

[player] Yes, I have. I met him during the war against the Southern kingdom. We were friends then.

[guide] Will he remember you?

[player] (sounding slightly offended) Of course he will. Would he have invited me otherwise?

[guide] Sorry, I did not mean to offend.

[player] (sighs) No offence taken. I spoke out of turn.

(a few seconds of silence)

[guide] Does Henrik know that you're...

[player] I don't believe so.

[guide] How will you tell him?

[player] He will see when he comes close enough. Knowing Henrik, he will probably be over-dramatic about it, but some things can not be helped.

[guide] I can see the manor up ahead. It's quite a nice looking thing.

[player] Henrik always was one for fancy decorations.

[guide] I'll say. I can scarcely imagine the amount of gold he-

[Henrik] Old friend, is that really you?! My, how the years have flown.

(the horses stop. sound of guide dismounting and Henrik walking towards them.)

[guide] Let me help you down, sir.

[Henrik] Who is this with you?

[player] My guide.

[Henrik] Why would you need a guide?

[player] (slightly sad voice) I'm blind, Henrik.

[Henrik] Dear lord...what happened?

[player] That is a story for another time, but I can say it was during the war, after we parted.

[Henrik] It pains me to see you like this. But no matter, now is not the time for bitter sadness. Tonight, we feast!

(Henrik leads the player and guide into his manor, where many conversations are taking place. Some people notice who Henrik is leading)

[guest 1] It's him...

[guest 2] No, it can't be.

[guest 3] Is he blind?

[guest 1] ...fought a dozen South-men, and won...


Next class I will continue the script.

Tuesday, June 13, 2017

Day 59: Audio-Only Game: Day 34

Continuing on from last class, the player will eventually find the necromancer in a random town (so it likely won't be the same for each playthrough). The player asks the necromancer for help, and he agrees, on the condition that the player find certain items that the necromancer would need, as well as gold to pay him. It will probably require three items. I don't know what they will be yet though. The player and the necromancer will then go search for the possessed necromancer. When they find him, the player will have to fend off his minions while the other necromancer starts the spell. After a bit, the player will be told to shoot the possessed necromancer with a crossbow bolt to help the spell work. Once that happens, the friendly necromancer can complete the spell, and destroy the spirits. I will probably have some sort of ending to the game after that.

In total, the game will probably have around 2-3 hours of gameplay, maximum. Maybe 4.

Friday, June 9, 2017

Day 58: Audio-Only Game: Day 33

The village 'elder' will tell the player a story about the necromancer. The necromancer tried to summon spirits, but messed up and was then possessed by them. The possessed necromancer, now with the ability and power to summon the dead, seeks to kill or enslave the living. The elder then tells the player that they can be stopped, but it would be hard. To stop them, the player needs to find another necromancer who can destroy the spirits possessing the other necromancer.

The player can then walk around in a relatively open-world map (guided by the different-sounding paths) going from town to town looking for a necromancer who is willing to help them. I might have around 10 towns or villages throughout the map. 

In one of the towns, I may also have a blacksmith that give the player a quest for a better (2-hit kill) sword. it won't be necessary to have the sword to complete the game, but it will make it easier. The blacksmith also won't be very easy to find.

Thursday, June 8, 2017

Day 57: Audio-Only Game: Day 32

 After escaping, the player finds themselves in a haunted forest, at night. I plan to have the player be guided by one voice, while others try to lead them astray. There may also be the odd wolf or bear that attacks the player.

The voice eventually leads the player to a small village, who's inhabitants are unaware of the attacks by the mage. After walking around and talking to people, the player may eventually come across the village "elder", who knows who the mage is, and where to go to find out how to defeat him.

Wednesday, June 7, 2017

Day 56: Audio-Only Game: Day 31

Continuing from last post, I plan to have the player get lost, and eventually come to a small castle or manor. The player's character will ask for directions, however, the lord of the manor/castle won't be nice. They will require the player to kill a small pack of wolves that has been hunting in their land.

The player will then go search for them, using sound to locate the wolves. After killing them (there will only be 3 or 4), the player will go back to the manor and tell the lord they killed the wolves. He will be surprised and angry, but will give the player directions to the capital.

Upon reaching the capital, the player will discover that the king has been killed, and his son put on the throne in his place. The player is framed for the assassination, and the new king immediately orders the player's execution, but right after, the necromancer attacks the capital, and the player is able to escape into the nearby forest.

Monday, June 5, 2017

Day 56: Audio-Only Game: Day 31

Making the variable would be easy. I just need to do the same thing as I did for the "Distance" variable. First of all, I made an integer variable named "Damage".

Next, I Added a line to each block of script that controls the weapon equipping. These lines set the amount of damage that will be dealt depending on the weapon.

Finally, I changed the Raycast function so that instead of subtracting 50 Health with each hit, it subtracts the "Damage" value instead.

Now that that's done, I can start planning the storyline of the game.

First off, the main player is blind. There should be some story behind how that happened. I plan to make the player a famous veteran of a war This is set in medieval times, probably somewhere between 1000 and 1400. I plan to make it an alternate universe, so it won't be historically accurate. As for why he's blind, it will probably be due to some accident either during or after the war.

The game will start with the player riding a horse, being guided by an aid, also on a horse. The veteran was invited by the leader (Jarl? Mayor? I don't know what the town leaders will be called) to a 'party' of sorts. Then, I will have a powerful enemy attack, maybe a sorcerer and some minor enemies. Something that can cause a lot of confusion. It will be up to the player to escape while killing any of the minor enemies in the way. I will probably add a blocking mechanic. The player will be one of the few survivors of the attack. The player's character will then offer to take news of the attack to the king. One of the surviving characters will say that he has no chance of making it that far. The player's character will ignore him, and leave anyways, using the sound of footsteps on the path to guide him.

Next class I will continue planning the storyline.

Friday, June 2, 2017

Day 55: Audio-Only Game: Day 30

So, I managed to figure out how to do what I needed without needing an answer on the forum.

My problem, was that I couldn't get the player controller script to access the "Health" variable in the Statistics script on the enemy that was hit. I tried a few different things yesterday, none of which worked. So, instead, I decided to follow a tutorial, and change it as needed.

first, I added a new private "storage" space.

Next, I added 2 lines to the Raycast function.

The second to last line adds the "Statistics" script of the enemy that was hit, to the 'statistics' storage space. The last line accesses the Health variable through the script stored in the storage space. It then sets the Health variable equal to the Health variable minus 50. So 50 health is removed each time.

Next class I will add a variable that changes the damage dealt depending on the weapon. The sword will probably do 35 damage, and the crossbow I'll have at 100 damage.

Thursday, June 1, 2017

Day 54: Audio-Only Game: Day 29

I tried to add couple lines of script that would allow me to access the Health variable in the script of the enemy that I hit, but it isn't really working. I've tried a few different things, but the problem is I don't know what to put after "hit.collider.gameobject._____".


So I asked a question on the forums.


Hopefully I'll get an answer by tomorrow. If so, I'll be able to continue it.


Wednesday, May 31, 2017

Monthly Post #4 - May in Review

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.


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.













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.










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.





















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.






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.


















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.





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.

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.