var Distance;
var Target = transform;
var lookAtDistance = 25.0;
var attackRange = 15.0;
var moveSpeed = 5.0;
var Damping = 6.0;
function Update ()
{
Distance = Vector3.Distance(Target.position, transform.position);
if (Distance < lookAtDistance)
{
lookAt();
}
if (Distance > lookAtDistance)
{
}
if (Distance < attackRange)
{
attack ();
}
}
function lookAt ()
{
var rotation = Quaternion.LookRotation(Target.position -
transform.position);
transform.rotation = Quaternion.Slerp(transform.rotation, rotation,
Time.deltaTime * Damping);
}
function attack ()
{
transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime);
}
I am trying to make my object go towards the player but i cant put anything in the slot where it prompts you to put the object i want it to follow the problem i believe is at line 2 but i have tried so many things and i cant do anything to fix it i would like to note i have another piece of code simialr to this in a different script and it works just fine.
Replace var Target = transform;
with var Target:Transform;
on line 2.