Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

BCE0051: Operator '

$
0
0
hello , im doing a Ai script that when you approche to the gameObject it will start following you ( i'm sure it's a classic basic script for Pro's ;) ) but im get tree same Errors: -BCE0051: Operator '<' cannot be used with a left hand side of type 'Object' and a right hand side of type 'float' in line 29.22 in line 36.22 and in line 42.22 pragma strict var Distance; var lookAtDistance : float = 25; var attackRange : float = 15; var animator : Animator; var target : Transform; var moveSpeed : float= 0; var rotationSpeed: float = 1; private var myTransform : Transform; //current transform data of this enemy private var controller : CharacterController; function Awake() { myTransform = transform; //cache transform data for easy access/preformance controller = GetComponent(CharacterController); // cache the CharacterController } function Start() { target = GameObject.FindWithTag("Player").transform; //target the player } function Update () { Distance = Vector3.Distance(target.position, transform.position); if (Distance < lookAtDistance) { animator.SetBool("idle" , true); animator.SetBool("walk" , false); } if (Distance > lookAtDistance) { animator.SetBool("idle" , true); animator.SetBool("walk" , false); } if (Distance < attackRange) { animator.SetBool("idle" , false); animator.SetBool("walk" , true); } // find the target direction: var dir: Vector3 = target.position - myTransform.position; dir.y = 0; // ignore height differences to avoid enemy tilting //rotate to look at the player myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(dir), rotationSpeed*Time.deltaTime); //move towards the player: controller.SimpleMove(myTransform.forward * moveSpeed); } at first i thought puting float's would work on the variables but it don't please help me!!

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>