Monday, February 25, 2019

Week 23 + 24

Week 23 + 24:

Creating An Enemy NPC - Part 4:

This week, I will now be making the “Monster” wander around the Map from a random position and have it just kind of patrol around the area. Additionally, I also wanted the “Monster” to become “Idle” and even “Attack” the Player. In order to do this, I began by re-opening the “Monster Script” began modifying the following pieces.


So, with this piece of coding the “Monster” is instructed to walk randomly around the “Map”. Working with the other coding, the “Monster” will walk towards the Player if they have spotted them and go “Idle” if they loose track of the Player.


So, now, with these pieces of coding added the “Monster” will now actively wander around the Map and an attempt to search for the “Player”. Upon locating the “Player”, the “Monster” will then give chase and follow the “Player”, and when they finally catch up to the “Player” the “Monster” will then kill them.  If they lose track of the “Player”, however, the “Monster” will return to its “Idle” state and attempt to re-search for the “Player”.

However, though, in order for me to be able to use this script completely I needed to create another script that allowed the “Monster” to see the “Player” character. In order to do this, I needed to create a cone but Unity does not use cones, so I needed to create a script that generates said cone. To do this, I went to the “Scripts” folder and created a new C# Script that I named “CreateCone”. I found a script for the cone from the Unity Wiki: http://wiki.unity3d.com/index.php?title=CreateCone


I then went into “CreateCone” and pasted the script into it. I then saved it and then dragged it into the “Editor” folder, and let it compile. In "GameObject, I then went into "Create Other" and was then able to generate the cone. In the box, I then edited the following "Num Vertices" = "10", "Radius Top" = "0.5", "Radius Bottom" = "3", "Length" = "8", "Opening Angle" = "0", added the "Outside" option and the "Add Collider" option.

 

I then clicked the “Create” button. Once I had created the “Cone”, I then renamed it “Eyes” before I dragged it and attached it to the “Monster”. I then pressed the “Reset” widget, so the cone shape would then appear on screen in front of the “Monster” itself and now the “Monster” itself should be able to see the “Player” when they appear in front of them. After this, I also clicked on the “Convex” and “In Trigger” options.


Finally for this week, I added some more code to the "Monster" script in order to work the "Cone" script I had found and added previously. Basically, this script works in tandem with the other script and makes everything in the above above scripts to work as intended. 

Monday, February 18, 2019

Week 22

Week 22:

Creating An Enemy NPC - Part 3:


Continuing from next week, I will now be animating the model of my "Monster" character. In order to do this, I began by creating a folder called “Animation” and then I created a “Animator Controller” that I called “Monster”. In the “Animator” section of the “Monster”, I then added the “Monster-Controller” to it and then went into “Window” > “Animator”.  In the “Animator” I clicked on “Parameters” and then I clicked the “+” symbol.


After clicking on the “+” symbol, I then picked “Float” and then I named it “Velocity”. Once I had done this, I need some animations, so I went into the uploaded “Models” folder I took from the Survival Shooter kit, and then went into “Characters”. In the “Import Settings” for the “Zombunny”, I then took their animates and added them to the “Zombear”. This is because “Zombear” does not have any animations but is compatible with “Zombunny”.


In the “clips” section, I then created a new “clip” and I named it “Listen”. I then took a piece from the “Idle” and cut it down from “170” to “230” in the “Start Frame”. I also made sure to click the “Loop Time” option and then I click the “Loop Pose” option.  As a result, this now “blends” the two together and allows them to work together a lot more seamlessly. Afterwards, I then clicked “Apply” and allowed this to compile before moving on.


Once I had this this, I then clicked on the “Move” clip and then I dragged the frame until the “Zombunny” was touching the ground. This was at “Frame 11”, I then went to “Events” and created a new “Event” I then called “Footstep”. In it’s “Int”, I simply made it “0” and then went to “Frame 26”, where I then did the same thing and also named it “Footstep” but this I time I made the “Int” into a “1”. I then clicked “Apply” for both of them.


I then dragged “Listen” and “Move” into the “Base Layer” for the “Monster”. I then right-clicked “Listen” and connected it to “Move”. In the “Transitions”, I then unclicked “Has Exit Time” and then clicked on the “+” symbol for the “Conditions” option. I then made the “Velocity” greater than “0.2”. Afterwards, I then right-clicked “Move” and connected it to “Listen”. Here, I then in the “Transitions”, I unclicked “Has Exit Time” and I made the “Velocity” less than “0.2”. So, now, when the “Monster” walks around they should get louder and quieter.

Monday, February 11, 2019

Week 21

Week 21:

Creating My Enemy NPC – Part 2:


This week I began by watching a few videos on how I could create a script for my Monster NPC, which’ll let it move around and follow the player. After looking around, I began by creating a “Script” folder and then a C# Script I called “Monster”. I then allowed it to compile and then I dragged it onto the “Monster”. From what you can see below, I ended up using the following script for my “Monster” NPC.


I then dragged the script onto the “Player”. With this, the “Monster” NPC will now head directly straight towards the “Player”. I then went into the “Monster”, then pressed “Add Component” and added “AudioSource”. There, in the “Audio Source” section I then unclicked “Don’t Play On Awake”, changed the “Spatial Blend” from “2D” > “3D”.



After this, I edited the “Min Distance” to “1” and the “Max Distance” to “20”. As a result of the this, when the “Monster” is further away this means the further away the sound of the footsteps is and the closer they are, the closest and loudest the footsteps are. I then went back into the “Monster” script and added the following pieces. 



On the “Player”, I ended up turning off their “Volume” and then I moved to the “Monster”. Here, I dragged “Footstep01”and “Footstep02” from the “Player” to the “Footsounds” in the “Monster” script on the “Monster”. Basically, this means, when the “Monster” takes a step then they’ll play the “Footsteps” located in the “Footsounds”.

Monday, February 4, 2019

Week 20

Week 20:

Creating My Enemy NPCs:


This week, I have began to work on the Enemy NPCs for my Unity Game. First, I began by uploading the Assets I needed from the Survival Horror Kit. This mainly consisted of the models/animations for the Enemy NPCs, such as the “Zombear” characters. Afterwards, I then dragged the “Zombear” onto the screen. I then clicked on them and then I renamed them from “Zombear” to that of “Monster”.


Afterwards, I then clicked on “Monster” and clicked on “Add Component”, and then I clicked on “AddNavMeshAgent”--  This’ll allow the “Monster” to move around. In the “NavMeshAgent”, I then changed the “Radius” from “0.5” to “0.38” and the “Height” from “2” to “1.27”. I then went into “Window” > “Navigation” and in the “Navigation” screen, I went into the “Bake” option and clicked “Bake”. Additionally, before I did that, I also made sure the “Baked Agent Size” options were the same as the “Radius” and “Height”. 







Week 34

Week 34: Critical Reflection: Conclusion: Over the course of this college year, I have managed to design, create and test my Horror-ba...