i have player and enemy in my game .THE enemy need to follow the player .please provide me a script to achieve this
public Transform target;
public float velocity = 10;
void Update()
{
transform.LookAt(target);
transform.Translate(Vector3.forward * velocity * Time.deltaTime);
}
put this code in gameObject follower.
@fabsk not working
put in your IA class ( C# )
ex:
using UnityEngine;
using System.Collections;
public class IA: MonoBehaviour
{
public Transform target;
public float velocity = 10;
void Update()
{
transform.LookAt(target);
transform.Translate(Vector3.forward * velocity * Time.deltaTime);
}
}
YA WORKING.thanks