O'Reilly logo

Mastering Unity 2D Game Development - Second Edition by Simon Jackson, Ashley Godbold

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Beefing up the enemy AI

At the moment, Dragon is just a sprite drawn on the screen with an AI system that just sits idle in the background. So, let's expand on this and give our Dragons some muscle power.

As stated earlier, to keep the player engaged, you need to have a varied amount of enemies in the battle and they need to be challenging enough to make the player think and apply tactics.

The enemy profile/controller

First, we'll create a new profile for the enemies, starting off with a new enumeration for the enemy class. Create a new C# script named EnemyClass in Assets\Scripts\Classes and replace its contents with the following code:

public enum EnemyClass 
{ 
  Dragon, 
  Blob, 
  NastyPeiceOfWork 
} 

I've used just a couple of examples, as we will only ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required