Preparing to attack a single enemy

Following on from the previous chapter, we will continue building our battle system.

Let's begin our focus on letting the player attack a single enemy. To do this, we'll add some variables to BattleManager to manage this.

We will also add some other elements to spruce up the battle, such as a selection circle or a target identifier, and add a variable to set a prefab for this.

So, open the BattleManager script and add the following variables to the top of the class:

private string selectedTargetName; private EnemyController selectedTarget; public GameObject selectionCircle; private bool canSelectEnemy; bool attacking = false; public bool CanSelectEnemy { get { return canSelectEnemy; } } public int EnemyCount { get ...

Get Mastering Unity 2D Game Development - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.