Hello everyone,
I have very beginner level with animations, thus a beginner question.
I have a enemy that attacks the player if close enough. I’m trying to get the mechanim to activate an attack animation when close to the player. The issue is the trasition between the enemy walking and attack isn’t functioning. I have called the walking state “Walk” and the attack state “Attack” with two transitions and added a trigger to each one of them.
Walk —>Attack (the trigger for the transition is called attack)
Attack —>Walk (the trigger for the transition is called walk)
I have just understood that I need a script to activate those but don’t really understand what’s online…
I’m trying to modify a script I found online but it gives me errrors
using UnityEngine;
using System.Collections;
public class TriggerScript : MonoBehaviour
{
Animator anim;
void Start(){
anim = GetComponent<Animator>();
}
void OnTriggerEnter(Collider other)
{
if(collision.transform.tag == "Enemy")
{
anim.setTrigger("Attack");
}
}
}
}
I’ll take any help given ![]()