Please, please answer one of my questions for once.
I am following Brackey’s survival game tutorial, and he is creating an Enemy AI script. When using it, I get this error: BCE0051: Operator ‘<’ cannot be used with a left hand side of type ‘Object’ and a right hand side of type ‘float’.
Here is my code:
var Target : Transform;
var lookAtDistance = 25.0;
var attackRange = 15.0;
var moveSpeed = 5.0;
var Damping = 6.0;
var Distance;
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);
}
In the tutorial, he solves it by taking away the pragma strict. As you can see, this is not working. Please help quickly!