Friday, September 29, 2017

TOE week 54: Very Variable Results



Discretion is the better part of something something. It would be cool if this was a blog about how I finally managed to tackle my Spotlight enemy problems. It would be cool if I could say that the things I tried worked and made the game tie together a little bit. It would be cool but it wouldn’t be true. 

I watch some different Youtube videos on game development. One of the series I watch is called Xtra Credits. I try to follow their advice about being an indy dev. One of the things they talked about was don’t stress about a problem that you can’t solve. Work on it and if it doesn’t work it is okay to give up and come back later. So I did that. The spotlight seemed to be not only something that didn’t work quite right but also something that was holding back other work. 

So I dropped this hot potato and moved onto a different AI. Something pretty easy. This new enemy is basically a mook enemy. It doesn’t do a lot and is easy/fun to kill. I named it a walker because that is all it does. It doesn’t even walk toward the player. It isn’t programmed to be smart enough to care. It walks until is it obstructed and if obstructed it turns around. If it touches the player it deals damage. It takes two hits and then dies. It was a very simple small victory. Probably a small victory that I needed too. 

That was cool. Then I made a different new enemy. This one I called a thrower. For this enemy I wanted to have much more random movements and random attacks. Step one was to make this enemy patrol side to side at a standard speed. AI asks itself ‘have I exceeded the limit on my position’? If so turn around. Step two was to then randomly change the limit point of enemy patrol. This led me to the discovery of Random.Range. A function that I believe is Unity specific but also pretty dope.  For the change of the patrol position it was just a die roll with a 25% chance of changing the position. Step three was to have another die roll that would randomly change the direction. Step four was then to have the enemy’s acceleration value also randomly redefine itself. 

Oh right this enemy was called thrower. Because it will randomly throw a projectile at the player.  The angle of the attack is random and the time between the attacks is also random plus a padding value. These projectiles seek the player’s position when the projectile is spawned. Turned out pretty well considering. When you put all of this together you get enemy that bounces around the level with no rhyme or reason. Leading to very variable results.  

Next week hopefully I will be able to make two more enemies! Or fix the one that is really bothering me.

No comments:

Post a Comment