- Home /
Unity, AI script errors... please help
Hello, I wrote an "EnemyAI" script... well i got it from a tutorial...
I checked tenth of times and I got everything right... but i just cant fix these mistakes ;(
These are my error messages... Please rewrite the script so it works, or tell me how to do it... Im so frustrated ;´(((
1. Assets/Scripte/EnemyAI.cs(28,58): error CS1061: Type UnityEngine.Transform' does not contain a definition for
postition' and no extension method postition' of type
UnityEngine.Transform' could be found (are you missing a using directive or an assembly reference?)
2. Assets/Scripte/EnemyAI.cs(28,20): error CS1502: The best overloaded method match for UnityEngine.Debug.DrawLine(UnityEngine.Vector3, UnityEngine.Vector3)' has some invalid arguments 3. Assets/Scripte/EnemyAI.cs(28,20): error CS1503: Argument
#2' cannot convert object' expression to type
UnityEngine.Vector3'
4. Assets/Scripte/EnemyAI.cs(31,61): error CS0103: The name my' does not exist in the current context 5. Assets/Scripte/EnemyAI.cs(31,148): error CS1061: Type
UnityEngine.Quaternion' does not contain a definition for rotationSpeed' and no extension method
rotationSpeed' of type UnityEngine.Quaternion' could be found (are you missing a using directive or an assembly reference?) 6. Assets/Scripte/EnemyAI.cs(31,55): error CS1501: No overload for method
Slerp' takes `2' arguments
Script is the following... it is writen in c sharp... on monodevelop I believ the programm is called... it comes with Unity I think.. ;/ Please Help!!
using UnityEngine; using System.Collections;
public class EnemyAI : MonoBehaviour { public Transform target; public int moveSpeed; public int rotaionSpeed; public int maxDistance;
private Transform myTransform;
void Awake() {
myTransform = transform;
}
// Use this for initialization
void Start () {
GameObject go = GameObject.FindGameObjectWithTag("Player");
target = go.transform;
maxDistance = 2;
}
// Update is called once per frame
void Update () {
Debug.DrawLine(target.position, myTransform.postition);
//Look at target
myTransform.rotation = Quaternion.Slerp(my.Transform.rotation, Quaternion.LookRotation(target.position - myTransform.position).rotationSpeed * Time.deltaTime);
if(Vector3.Distance(target.position, myTransform.position) > maxDistance) {
//Move towards target
myTransform.position += myTransform. forward * moveSpeed * Time.deltaTime;
}
} }
End of Script
These are the exact error messages and this is the exact script... Please Help me!!
I hope somebody can fix this... Thanky you!!! Please! ; /
thx!
-Luis
Your answer
![](https://koobas.hobune.stream/wayback/20220612224102im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
ERROR unity expected. insert a semicolon at the end 2 Answers
Delay between animations 1 Answer
Errors with script using Javascript. 2 Answers
Script error help ? 1 Answer
Enemy AI Help? 1 Answer