Today I started adding enemy AI. I found a tutorial about adding a simple AI to an object to make it attack when the player is in range.
The tutorial, unfortunately, used JavaScript, however, someone put the C# 'translation' of the script in the comments. I copy/pasted it into a script called "EnemyAI" and set the main camera to be the 'player' that the enemy attacks.
Now the enemy moves towards the player once it's within a specific distance. Unfortunately however, the enemy sometimes seems to drift to the side after the player moves out of range, instead of stopping completely. There's nothing I can do about it right now, so I'll have to leave it for now.
Next class I will add a damage mechanic. At some point, I'll also have to refine the raycast system. I still haven't been able to make it cast a single ray on click.
Wednesday, May 3, 2017
Friday, April 28, 2017
Monthly Post #3 - April in Review
What I Learned This Month
-How to add a delay into a C# script
-How to make a raycast with a limited length
-How to add a pause mechanic
-How to add a ui that appears when a button is pressed
-How to add a slider that controls an integer value
What I Accomplished
This month I continued making my audio-only game. I've added a main menu, a pause menu that appears when "escape" is pressed, a raycast that will be used for the combat mechanics, and added a delay that simulates drawing a sword.
Next month, I will start adding enemies. The pathfinding won't need to be very complicated; they just have to move towards the player, then deal damage per second to the player when it touches.
-How to add a delay into a C# script
-How to make a raycast with a limited length
-How to add a pause mechanic
-How to add a ui that appears when a button is pressed
-How to add a slider that controls an integer value
What I Accomplished
This month I continued making my audio-only game. I've added a main menu, a pause menu that appears when "escape" is pressed, a raycast that will be used for the combat mechanics, and added a delay that simulates drawing a sword.
Next month, I will start adding enemies. The pathfinding won't need to be very complicated; they just have to move towards the player, then deal damage per second to the player when it touches.
Thursday, April 27, 2017
Day 40: Audio-only Game: Day 15
So, I finally figured out how to add the WaitForSeconds delay into the script. I first made a new void function:
I then added "StartCoroutine", and gave the coroutine a name: "Wait".
Finally, I added an IEnumerator with the "Wait" coroutine name. Inside that, I added "yield return WaitForSeconds(3);", and then a line afterwards that changes the CanAttack boolean to true.
I then simply added a line that calls the WaitToAttack function whenever the "1" or "2" key is pressed, effectively adding a delay that simulates drawing a sword, orpulling out a bow.
Tuesday, April 25, 2017
Day 39: Audio-only Game: Day 14
Are. You. Kidding me? So much for getting an answer! On to the audio!
Anyways, I first need some sound effects. I found a sfx pack on the unity asset store, and some other sound effects on a sound effects website:
http://www.sounddogs.com/previews/101/mp3/129686_SOUNDDOGS__bo.mp3
http://www.sounddogs.com/previews/2742/mp3/456574_SOUNDDOGS__bo.mp3
http://www.sounddogs.com/previews/101/mp3/129696_SOUNDDOGS__cr.mp3
Unfortunately I couldn't find any guides for audio that make sense, but I did get some more script added to the game. I added a delay between switching weapons and being able to attack, using a boolean called "CanAttack", and a WaitForSeconds function.
Anyways, I first need some sound effects. I found a sfx pack on the unity asset store, and some other sound effects on a sound effects website:
http://www.sounddogs.com/previews/101/mp3/129686_SOUNDDOGS__bo.mp3
http://www.sounddogs.com/previews/2742/mp3/456574_SOUNDDOGS__bo.mp3
http://www.sounddogs.com/previews/101/mp3/129696_SOUNDDOGS__cr.mp3
Unfortunately I couldn't find any guides for audio that make sense, but I did get some more script added to the game. I added a delay between switching weapons and being able to attack, using a boolean called "CanAttack", and a WaitForSeconds function.
Monday, April 24, 2017
Day 38: Audio-only Game: Day 13
Today I found out that I didn't even reply to Commoble's answer. Instead I just added a reply on my question. So today, I deleted my comment, and re-posted it as a reply to their answer.
So, while I wait for the answer (again), I added some script that sets the distance of the combat raycast depending on what weapon is being used. Pressing '1' switches the distance to 3 for a sword, and pressing '2' sets the distance to 100 for a bow.
I spent the rest of the class looking for sword and bow sound effects. Next class, I will learn how to add audio to my game.
So, while I wait for the answer (again), I added some script that sets the distance of the combat raycast depending on what weapon is being used. Pressing '1' switches the distance to 3 for a sword, and pressing '2' sets the distance to 100 for a bow.
I spent the rest of the class looking for sword and bow sound effects. Next class, I will learn how to add audio to my game.
Thursday, April 20, 2017
Day 37: Audio-only Game: Day 12
So I got an answer to my question. I just need to see if it works.
So, I put the second part of the script in, but I don't know where I would put the first part of the script (the one that starts with "ScriptType"). I also don't know if I even put it in the right place.
I replied to the answer by "Commoble" asking where I would put it. Now I just need to wait again.
Now to add to the Statistics script. I added some script that destroys a game object after 3 seconds, if its health variable is equal to or less than 0.
So when its health reaches 0, it disappears after 3 seconds.
The 3 seconds allows for death sounds and anything else that might happen when an enemy dies.
Next class I will hopefully be able to continue with the raycast script.
So, I put the second part of the script in, but I don't know where I would put the first part of the script (the one that starts with "ScriptType"). I also don't know if I even put it in the right place.
I replied to the answer by "Commoble" asking where I would put it. Now I just need to wait again.
Now to add to the Statistics script. I added some script that destroys a game object after 3 seconds, if its health variable is equal to or less than 0.
So when its health reaches 0, it disappears after 3 seconds.
The 3 seconds allows for death sounds and anything else that might happen when an enemy dies.
Next class I will hopefully be able to continue with the raycast script.
Wednesday, April 19, 2017
Day 36: Audio-only Game: Day 11
I needed a way for the raycast to interact with objects. First I made a RayCastHit variable called "WhatIHit".
Next, I added some script in the "if" statement that stores the data for the item the raycast hit in the variable.
Next, I changed the Debug.Log so it would output "I hit" and then the the name of the object it hit, which I accessed through the collider of the object.
As you can see, the console is outputting "I hit terraaced1am", which is the name of the house model that the raycast is touching.
Now to have the raycast subtract health from a character. I made a new capsule object called "enemy" just to test it, and gave it a RigidBody.
I then added the Health script on to it. The script only contains the health variable, and nothing else for now.
Unfortunately I don't yet know how I would have the raycast change the variable on hit. So far, I have enough script for it to access a component, but I don't know how to specify which component, or how to change a variable in the component.
I posted a question on the Unity3D forum, so hopefully I'll have an answer in a couple days or so.
Until then, I'll add more to the Health script.
Subscribe to:
Posts (Atom)

























