Game Development Reference
In-Depth Information
Finally, drag the object from the
Scene
hierarchy into
Assets\Prefabs\Props
to
create the prefab, ensuring its name is
SelectionCircle
. Then, delete the object from
the scene as we no longer need it.
Now, in the
Battle
scene, in the editor, select the
BattleManager
game object in the
Pro-
ject
hierarchy; once you do this, drag the
SelectionCircle
prefab on to the
Selec-
tion Circle
property for the
BattleManager
script to attach it to the
BattleManager
game object.
Adding selection logic to the EnemyController class
With everything set up in the
BattleManager
game object, we can now return to the
EnemyController
script and repeat the process we used with
CommandButton
so
the player can click on the Goblins to highlight them.
First, we need a couple of properties in the
EnemyController
script to keep a referen-
ce to our
SelectionCircle
prefab and determine whether the current enemy is selec-
ted or not. So, add the following to the top of the
EnemyController
class: