Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

EnemyAI Script help

$
0
0
Hey guys I have a EnemyAI Script, but I always the error "Operator < Cannot be used with a left hand side of type "object" and a right hand side of type "float". Once And "Operator < Cannot be used with a left hand side of type "object" and a right hand side of type "float". Three times Here is the script, Thanks For Your Help! 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); }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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