Hi, i’m really new to this forum so i hope that i post things right. I’ve been following a tutorial on a script for an AI to follow you and change colors depending on the distance, i kept stumbling into the same errors.
Assets/AISimple.js(32,84): BCE0043: Unexpected token: ).
Assets/AISimple.js(32,65): UCE0001: ‘;’ expected. Insert a semicolon at the end.
Assets/AISimple.js(32,64): BCE0044: expecting ), found ‘=’.
Here’s the code
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)
{
renderer.material.color = Color.yellow;
lookAt();
}
if (Distance > lookAtDistance)
{
renderer.material.color = Color.green;
}
if (Distance < attackRange)
{
renderer.material.color = Color.red;
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);
}