Hello guys
So i been trying to make some simple Ai for my enemy in Unity and i run into a problem that i cant solve
function LateUpdate () {
if(Vector3.Distance(player.position, this.transform.position) < 20) {
var direction : Vector3 = player.position - this.transform.position;
direction.y = 0;
this.transform.rotation = Quaternion.Slerp(this.transform.rotation, Quaternion.LookRotation(direction), 0.1f);
if(direction.magnitude > 2) {
this.transform.Translate(0,0,0.05f);
}
else if (direction.magnitude <= 2) { //&& direction.magnitude > 2) {
this.transform.Translate(0,0,-0.05f);
//anim.SetTrigger("Atakuoja");
}
}
}
So this simple script is bassicly checking does enemy see the player if he does he moves until he is 5 blocks away i wanted him from that spot to attack the player well jump on him (its a wolf) i tried to script it and i ran into countless problems so i thought hey i can just set trigger to activate animation when he gets close enough. Problem is if i create attack animation (iam using low poly model made by myself in blender its novice model no bones no nothing etc. ) the script doesnt affect wolfs movements anymore so bassicly if animation has parameters for position script wont be able to change wolves position so could i get some help or at least some kind of link to tutorial for my issue
script Picture: Imgur: The magic of the Internet