Game Development Reference
In-Depth Information
using System.Collections;
using UnityEngine;
public class EnemyController : MonoBehaviour {
private BattleManager battleManager;
public Enemy EnemyProfile;
Animator enemyAI;
public BattleManager BattleManager
{
get
{
return battleManager;
}
set
{
battleManager = value;
}
}
}
The preceding code gives us the missing EnemyController class that we used in the
BattleManager script with the following properties:
• A tight reference to the BattleManager script, which is needed because the
enemies are directly affected by the battle as it is ensued
• The enemy profile
• A reference to the AI animator controller we created in Chapter 7 , Encountering
Enemies and Running Away
As the AI needs information about the battle, we need to ensure that it has kept each
frame up to date. So, for this, we add an UpdateAI method and call it from the Update
method to keep the AI up to date, as follows:
void Update()
{
UpdateAI();
}
Search WWH ::




Custom Search