Sunday 28 February 2016

Coding - AI Iteration 2 and Combat - John Howard

Overview

Firstly its been a while since i've posted basically an entire month! But thats not been a month in vain. Since the last iteration I have decided to do a complete new iteration of the code that I had and put on a moving cube. This is so as to just code the AI without animation so I can focus fully on the code and then move the working code to the golem model when ready.
General Script Iteration
I went through all the scripts mentioned previously within this blog and redid the code from scratch using the previous ones as reference. Mostly nothing was changed with just the few cleanups and the like. The patrol and the search stayed as the last iteration due to having already changed these two scripts to a higher level already.

Animator

Due to the model now being a cube, and no rig, I set up a completely new animator along with unity animation. I gave the model two hands that moved back and forth to show when the AI was moving and a second state that would stop them moving when in combat. The transition between the non-combat and combat states happen when a combat bool becomes true. I also implemented a punch and slam animation. These two movements were chosen due to the group asking for these two attacks. Again two bools are set up ready to call these. Setting up an animator has become an easy enough task for me now however I haven't touched layers yet. But a bit of research into layers via tutorials and the API have cleared this up and suggests the use of layer masks could be a good route to go depending on how the group wants the golem AI to work in combat.
Current AI animator

Combat Scripts

The AI has two attacks a punch, and a slam. With the slam being the more powerful one. Thus I wanted to make it more likely for the AI to use the punch rather than the slam. So I created an array of five ints from 1 to 5. Odd numbers would turn on the anim bool for the punch whilst even numbers would initiate the slam. The slam when called would then have a cooldown preventing it being called until the slam is ready again. This works rather well for an initial setup but again a second iteration of this is needed at least. I'm tempted to move this into coroutine like I did with the other scripts. In all honesty I should really be doing this straight away. But development is development after all. Furthermore the punches and slams do not have triggers for now as I still must wait for the player controller to be setup. I hope this is soon as testing with the rough one I set up is not how the game will actually play.

No comments:

Post a Comment