Hello everybody, this is my C# Script:
using UnityEngine;
using System.Collections;
public class EnemyAI : MonoBehaviour {
public Transform Target;
private GameObject Enemy;
private GameObject Player;
private float Range;
public float Speed;
// Use this for initialization
void Start () {
Enemy = GameObject.FindGameObjectWithTag ("Enemy");
Player = GameObject.FindGameObjectWithTag ("Player");
}
// Update is called once per frame
void Update () {
Range = Vector2.Distance (Enemy.transform.position, Player.transform.position);
if (Range <= 15f) {
transform.Translate(Vector2.MoveTowards (Enemy.transform.position, Player.transform.position, Range) * Speed * Time.deltaTime);
}
}
}
Now, this script work for 3 seconds (in this time i move to two different directions whit the player) , but when i try to move in a third different direction the Enemy still goes in the previous direction! Is that a script problem? Help me please!
[I’m italian, so dont speak strong english… use easy words ]