I have a problem with the enemy path finding script I tried it myself then I fixed any issue I had by watching ben . But the enemy is still chasing me with out getting close to it I set both character and enemy atleast 100 meters apart and the enemy is still coming to me with out me moving this is what I have .
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityStandardAssets.Characters.ThirdPerson;
public class Enemy : MonoBehaviour {
[SerializeField] float maxHealthPoints = 100f;
[SerializeField] float attackRadius = 4f;
float currentHealthpoint = 100f;
AICharacterControl aiCharacterControl = null;
GameObject player = null;
public float healthAsPercentage
{
get
{
return currentHealthpoint / (float) maxHealthPoints;
}
}
void start()
{
player = GameObject.FindGameObjectWithTag ("Player");
aiCharacterControl = GetComponent<AICharacterControl> ();
}
void update ()
{
float distanceToPlayer = Vector3.Distance (player.transform.position, transform.position);
if (distanceToPlayer <= attackRadius) {
aiCharacterControl.SetTarget (player.transform);
} else {
aiCharacterControl.SetTarget (transform);
}
}
}