WebGL build: https://simmer.io/@Derek_G/robot-runner
I finally finished my game that started life as the Zombie Runner project for the Complete C# Unity Game Developer 3D course, going off in my own direction around the pro-builder section of the course.
I did 3 weeks of evening and weekend programming. Let it collect dust for a few months, then finally put in a fourth week of polish and bug fixing.
Like any IT coding project there was lots and lots of googling - for both the little things and the big things.
My biggest problem by far was the AI for the Enemy, which I couldn’t find any good guides on. It ended up being a rather complex state machine I rewrote several times. With the code being a mix of stuff I am both proud and ashamed of
I eventually ended up with an EnemyAI that acts as a selector for more complex behaviour patterns like EnemyGuardAI and EnemyHuntAI. Each having several sub states of their own governed by enum types. If you were to visualize the code it would look like an animator or graph diagram. Calculate if a transition is needed, if a transition is needed, execute the transition, then execute the state frame by frame like an animation.
void Update()
{
EnemyState newState = StateCalcEnemy();
StateTransition(newState);
enemyState = newState;
StateExecute();
}
One thing I learnt from taking this course is: you need to put in your own time and practice, no one will do it for you.