Hi!
I’m trying to play animations based on what I write in the Inspetor/String.
public class Activity
{
public string animation; // The name of the animation to play
public Transform location; // Location at which the activity should be performed
}
if (Vector3.Distance(transform.position, activity.location.position) < tolerance)
{
// Play the animation for the activity
animator.SetTrigger(activity.animation);
Debug.Log("PLAYING MY ANIMATION OF CHOICE");
}
// If the NPC is not at the location of the activity, move to the location
else
{
animator.Play("Walk");
}
The Animator and inspector look like this (Image Attached) - But I have noooo clue how to set it up in the Animator. I’ve learned I should write “” on the names in the Inspector. But nothing happens…
The animator manage to play the “Walk” animation, but thats only cuz its written in the script.
The other activites I want to write myself in the Inspector so I can make sure all NPC are doing different thing etc.
I rather not use triggers between 10-20 animations. So I want the Animation written in the Inspector to play.
Any idea how to do this? Is it possible?
Thankful for help!