I’m making a boss enemy for my fps that has two attacks that he will choose from at random When the timer = the fire rate, the enemy should generate a number that will be the attack. But for some reason, the enemy won’t generate a number. Here’s the Code
#pragma strict
var health : int;
var biteDamage : int;
var enemyChoice : int;
var fireRate : float;
var fireTimeRemaining : float;
var player : Transform;
var agent : NavMeshAgent;
var animationThing : Animation;
var attacking : boolean;
function Start ()
{
animationThing = GetComponent(Animation);
agent = GetComponent(NavMeshAgent);
player = GameObject.FindWithTag("PlayerDetection").transform;
}
function Awake()
{
attacking = true;
animationThing.Play("Armature|roar");
fireTimeRemaining = fireRate;
}
function Update ()
{
fireTimeRemaining -= Time.deltaTime;
if(!animationThing.IsPlaying("Armature|roar") || !attacking)
{
attacking = false;
agent.destination = player.position;
animationThing.Play("Armature|walk");
}
if(fireTimeRemaining <= 0)
{
fireTimeRemaining = fireRate;
}
if(fireTimeRemaining == fireRate)
{
var randomAttack = Random.Range(0,2);
attacking = true;
enemyChoice = randomAttack;
Debug.Log("attacked");
}
}