DevLog #4 Enemies!

brainwipe on Wed, 2017-09-13 22:16

After my previous attempt at getting bad guys to move around, I hit YouTube hard in my lunch breaks and discovered that lots of people repurpose the inbuilt animator finite state machine for doing most AI.

SMELLY

This is a code smell. Every domain object and class should do one job and do it well. Repurposing suggests that you're bending a system for something that it wasn't intended for (single responsibility principle). However, I thought it was best to just get over myself, give it a go and then come back again later.

I added an animator, created some states, gave each state a script file (adding a base class to be tidy) and added a transition that would make the enemy follow the player. Once it's locked on, there's no getting away from it just yet!

It works well but the enemy movement is a bit simplistic, giving some jerky movements. I intend to make the movement work in the same way as the player Cloudship.