using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class enemyAI : MonoBehaviour
{
//Distance entre le joueur et le zombie
private float Distance;
// cible du zombie
public Transform Target;
//distance de poursuite
public float chaseRange = 10;
//portée des attaques
public float attackRange = 2.2f;
//Cooldown des attaques
public float attackRepeatTime = 1;
private float attackTime;
//Dégats infligés
public float TheDammage;
//Agent de navigation
private UnityEngine.AI.NavMeshAgent agent;
//Animation du zombie
private Animator animation;
void Start()
{
agent = gameObject.GetComponent<UnityEngine.AI.NavMeshAgent>();
animation = gameObject.GetComponent<Animator>();
attackTime = Time.time;
}
void Update()
{
//on cherche le joueur en permanence
Target = GameObject.Find("Player").transform;
//Calcul de la distance zombie player pour effectuée diverse action
Distance = Vector3.Distance(Target.position, transform.position);
//Quand player loin = idle
if (Distance > chaseRange)
{
idle();
}
//Quand zombien'est pas asser proche pour attaquer
if (Distance < chaseRange && Distance > attackRange)
{
chase();
}
//Quand zombie peut attaquer
if (Distance < attackRange)
{
Attack();
}
//poursuite
void chase()
{
animation.Play("walk");
agent.destination = Target.position;
}
//combat
void Attack()
{
// empêche le zombie de traverser le player
agent.destination = transform.position;
//si pas de cooldown
if (Time.time > attackTime)
{
animation.Play("Hit");
Target.GetComponent<PlayerInventory> ().ApplyDamage(TheDammage);
Debug.Log("Le zombie a frappé" + TheDammage + "point de dégats");
attackTime = Time.time + attackRepeatTime;
}
}
//idle
void idle()
{
animation.Play("idle");
}
}
}
I have errors on the unit about my code but I have no error on visual studio
Asset/enemyAI.cs(67,9):error CS1547:Keyword 'void' cannot be used in this context
Asset/enemyAI.cs(67,18):error CS1525: Unexpected symbole '(',expecting ',','';' or'='
Asset/enemyAI.cs(93,0):error CS1525: Unexpected symbole '}'
I did not try anything because I really did not understand.