Hi, I’m new on Unity and I want to create a game but I have a problem and I’m stuck.
The console says : Assets/AI/ZombieAI.js(29,16): BCE0051: Operator ‘<’ cannot be used with a left hand side of type ‘Object’ and a right hand side of type ‘int’.
This is my script :
#pragma strict
var Distance;
var Target : Transform;
var LookAtDistance = 30;
var chaseRange = 15;
var attackRange = 2.2;
var moveSpeed = 3;
var Damping = 5;
var attackRepeatTime = 0.5;
var TheDammage = 5;
private var attackTime : float;
var controller : CharacterController;
var gravity : float = 20;
private var MoveDirection : Vector3 = Vector3.zero;
function Start () {
attackTime = Time.time;
FindHealth();
}
function Update () {
Distance = Vector3.Distance(Target.position, transform.position);
if(Distance < LookAtDistance){
lookAt();
}
if(Distance < attackRange){
attack();
}
else if(Distance < chaseRange){
chase();
}
}
function lookAt(){
var rotation = Quaternion.lookRotation(Target.position - transform.position);
trasform.rotation = Quaternion.Slerp(transform.rotation, rotation,Time.deltaTime * Dampling);
}
function chase(){
GetComponent.().Play(“walk”);
moveDirection = transform.forward;
moveDirection *= moveSpeed;
moveDirection.y -= gravity * Time.deltaTime;
controller.Move(moveDirection * Time.deltaTime);
}
function attack(){
if(Time.time > attackTime){
GetComponent.().Play(“attack”);
Target.SendMessage(“ApplyDammage”, TheDammage);
Debug.log(“The ennemy has attacked”);
attackTime = Time.time + attackRepeatTime;
}
}
function ApplyDammage(){
chaseRange += 35;
moveSpeed += 2;
LookAtDistance += 45;
}
function FindHealth(){
Target = GameObject.Find(“PlayerSats”).GetComponent(PlayerStats).transform;
}
The line affected is : if(Distance < LookAtDistance){
Thank’s to help me!