- Home /
 
 
               Question by 
               thefilmmaker · Jun 08, 2015 at 10:52 AM · 
                aienemyenemy aienemyaiparsing error  
              
 
              Simple AI Error 8025 Parrsing error.
i have looked many times over this but i cant find the error. Anyone who can help me :P
 using UnityEngine;
 using System.Collections;
 
 var target : Transform; //the enemy's target
 var moveSpeed = 3; //move speed
 var rotationSpeed = 3; //speed of turning
 var range : float=10f;
 var range2 : float=10f;
 var stop : float=0;
 var myTransform : Transform; //current transform data of this enemy
 
 public class Enemy AI Simple : MonoBehaviour{
 
 function Awake()
 {
     myTransform = transform; //cache transform data for easy access/preformance
 }
 
 function Start()
 {
     target = GameObject.FindWithTag("Player").transform; //target the player
     
 }
 
 function Update () {
     //rotate to look at the player
     var distance = Vector3.Distance(myTransform.position, target.position);
     if (distance<=range2 &&  distance>=range)
     {
         myTransform.rotation = Quaternion.Slerp(myTransform.rotation,
         Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime);
     }
     
     
     else if(distance<=range && distance>stop){
         
         //move towards the player
         myTransform.rotation = Quaternion.Slerp(myTransform.rotation,
         Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime);
         myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
     }
     else if (distance<=stop) {
         myTransform.rotation = Quaternion.Slerp(myTransform.rotation,
         Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime);
     }
     }
 }    
 
              
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by HarshadK · Jun 08, 2015 at 10:52 AM
The variable declaration should be done inside the class.
Methods need a return type like 'void' instead of the keyword 'function' before them.
Plus what tanoshimi has specified in his answer.
 
               Best Answer 
              
 
              Answer by tanoshimi · Jun 08, 2015 at 11:56 AM
Your problem is that you're using a mixture of C# syntax (e.g. using directives, public class Enemy AI Simple : MonoBehaviour declaration) and UnityScript syntax (e.g. var target : Transform; and function Start()) - it's not entirely clear which you're intending to use, but you need to be consistent! 
Your answer