Week 9 - Enemies & Interaction


Working with the Bad Guys

Hey all,

Another week, another update! This week we focused on getting the player interactions and enemies working. For this game it meant getting the enemies moving and looking swank.  

Enemies

I started off by building the sprite sheets of each of enemies, Skeleton, Goblin, Ghoul and Golem. 


I then went on to create the base enemy prefab, giving it a basic wandering script for when it's cruising around doing enemy stuff, a seek script for when it spots the player, an animation controller for activating the sprites when I add them and finally a Killable script so they can die when lazored.

From there, I copied the prefab a few times and began adding all the sprite sheets to the appropriate prefabs, renaming to their proper name as I went. While I did this I also changed a few minor settings to give the enemies some small differences (which I'm still working on), such as goblins moving the fastest and golems moving the slowest.


Seek

After this was down, I went to work on the Seek script to get it working to find the player. The first issue I had was the fact that it was attached to a prefab, meaning that I wouldn't be able to just drag the target into the public slot on the script, it would need to find the target itself once it was spawned. For this I use the FindWithTag operator so the enemies could search for a GameObject with the Tag "Player".
But just having them auto lock on to the player as soon as they spawn wasn't going to be much fun now was it? So I thought to myself, what about the player firing off some RayCasts, and if one hits an enemy that THEN seek would activate, so as to seem like the enemy has just "seen" the player and gives chase. So that what I did. I added a 360Raycast script to the player and set it so that if it hit an object that had the Seek script on it, it would activate it. Sorted.


Lazor

Right, time to get into what the game is all about, FIRING MA LAZOR!!!
I added a script from the tutorials called Shoot, but heavily modified. Originally it was for firing bullets, but I changed that (with alot of help from Lindsay and Ian, cheers!). I begins by, when the player clicks with the Left Mouse Button, waiting a very small amount of time (this is for the Zapping animation to activate), and then shoots out a Raycast to the mouse position. This raycast bounces off a few walls up to a maximum amount of bounces (or "Ricochets"), and then attaches a Line renderer to it, creating the Lazor! 
Now, if the Lazor hits an enemy before it reaches the maximum amount of ricochets, then it stops and destroys the enemy (upcoming patch hopefully will include HP for the enemies). In addition to this, an unintentional bug but one I was trying to figure out and it just worked that way, was that if you fire the Lazor directly at an enemy, it will bounce off them leaving them unharmed. Now this wasn't something we had planned on, but it Was something I was trying to figure out how to do. Bugs FTW!


Miscellaneous additions

After all of that, I also added in the Dialogue scene which offers up the backstory of Doug the mage, and the Controls scene which shows the player how to play. Not much to say about those, I just used a tilemap with tiles from the Random Level Generator to create the background, added some text and a button to move onto the next scene.



Hope you all are enjoying it so far, I know I am in making it.

See you in a week for the next update.

Files

18 Sept.zip Play in browser
Sep 18, 2020

Leave a comment

Log in with itch.io to leave a comment.