started working inventory system
This commit is contained in:
@@ -13,12 +13,7 @@ public class Enemy : Character
|
||||
|
||||
private State curState = State.Idle;
|
||||
|
||||
[Header("Ranges")]
|
||||
[SerializeField] private float chaseRange;
|
||||
[SerializeField] private float attackRange;
|
||||
|
||||
[Header("Attack")]
|
||||
[SerializeField] private float attackRate;
|
||||
private float lastAttackTime;
|
||||
[SerializeField] private GameObject attackPrefab;
|
||||
|
||||
@@ -75,30 +70,30 @@ public class Enemy : Character
|
||||
// Called every frame while in the IDLE state.
|
||||
void IdleUpdate()
|
||||
{
|
||||
if (targetDistance < chaseRange && targetDistance > attackRange)
|
||||
if (targetDistance < ChaseRange && targetDistance > AttackRange)
|
||||
SetState(State.Chase);
|
||||
else if (targetDistance < attackRange)
|
||||
else if (targetDistance < AttackRange)
|
||||
SetState(State.Attack);
|
||||
}
|
||||
|
||||
// Called every frame while in the CHASE state.
|
||||
void ChaseUpdate ()
|
||||
{
|
||||
if (targetDistance > chaseRange)
|
||||
if (targetDistance > ChaseRange)
|
||||
SetState(State.Idle);
|
||||
else if (targetDistance < attackRange)
|
||||
else if (targetDistance < AttackRange)
|
||||
SetState(State.Attack);
|
||||
}
|
||||
|
||||
// Called every frame while in the ATTACK state.
|
||||
void AttackUpdate ()
|
||||
{
|
||||
if (targetDistance > attackRange)
|
||||
if (targetDistance > AttackRange)
|
||||
SetState(State.Chase);
|
||||
|
||||
Controller.LookTowards(target.transform.position - transform.position);
|
||||
|
||||
if(Time.time - lastAttackTime > attackRate)
|
||||
if(Time.time - lastAttackTime > AttackRate)
|
||||
{
|
||||
lastAttackTime = Time.time;
|
||||
AttackTarget();
|
||||
|
||||
Reference in New Issue
Block a user