- Home /
Conflicting Animator SetTrigger
Apologies in advance, I'm very new and I'm sure my code is horribly ugly.
I've made up a very simple little Tamagotchi style game where you look after a frog.
Frog has needs that depreciate over time. It's a super simple setup so that it's idle animation is Happy, unless any of it's needs drop below 50, when Sad is triggered.
I'm trying to add the Croak animation when the Feed button is pressed. It works when it's needs are over 50, presumably because it's using it's idle anim, but I can't quite figure out how to overwrite the Sad trigger, as the Croak animation doesn't trigger if the pet is already Sad. I'm guessing it's to do with my If statements, I'm sure it's something simple that I'm missing.
Here's the section that triggers the animations (TaskonClick is another Animator.SetTrigger for Croak):
{
Button btn = Feed.GetComponent<Button>();
btn.onClick.AddListener(TaskOnClick);
}
if (Needs.Happiness < 50)
{
PetAnimator.SetTrigger("Sad");
}
if (Needs.Energy < 50)
{
PetAnimator.SetTrigger("Sad");
}
if (Needs.Food < 50)
{
PetAnimator.SetTrigger("Sad");
}
Your answer
Follow this Question
Related Questions
Issue with mecanim playing an animation using setbool 1 Answer
Unity 5 Broken Animations? 3 Answers