Alrighty, so i threw together this little AI script that i’m going to use in my game. I decided to use the Free spawner system made by Corupted smile studio. In order for me to do this i think i need to change the target transform to a tag but i don’t know how to call a tag in my script. The script is in C#.
using UnityEngine;
using System.Collections;
public class EnemyAI : MonoBehaviour {
public Transform Target;
public int movespeed;
public int rotationspeed;
private Transform MyTransform;
void Awake() {
MyTransform=transform;
}
// Use this for initialization
void Start () {
GameObject go = GameObject.FindGameObjectWithTag("Player");
Target = go.transform;
}
// Update is called once per frame
void Update () {
Debug.DrawLine(Target.position, MyTransform.position, Color.red);
//look at target
MyTransform.rotation = Quaternion.Slerp(MyTransform.rotation, Quaternion.LookRotation(Target.position - MyTransform.position), rotationspeed * Time.deltaTime);
//Move Towards Target
MyTransform.position += MyTransform.forward * movespeed * Time.deltaTime;
}
}