Im doing a semple script for AI in my game and i need a little help … what is the problem with my script ?`using UnityEngine;
using System.Collections;
public class WeakAI : MonoBehaviour {
float Distance;
public Transform Target ;
double lookAtDistance = 25.0;
double attackRange = 15.0;
float moveSpeed = 5 ;
double Damping = 6.0;
void Update ()
{
Distance = Vector3.Distance(Target.position, transform.position);
if (Distance < lookAtDistance)
{
renderer.material.color = Color.yellow;
lookAt();
}
if (Distance > lookAtDistance)
{
renderer.material.color = Color.green;
}
if (Distance < attackRange)
{
renderer.material.color = Color.red;
attack ();
}
}
void lookAt ()
{
Transform rotation = Quaternion.LookRotation(Target.position - transform.position);
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * Damping);
}
void attack ()
{
transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime);
}
`