OnMouseExit triggering when its not supposed to
I'm currently designing my main menu, basically I'm trying to make it so when the mouse hovers over a button, it will play one animation, then move to another looping animation. (yes i have loop time turned on and off respectively) then when the mouse moves away from the button it plays an animation and returns to it's original state.
but for some reason, while the mouse is over the button it continually changes the bool that tells it weather or not the mouse is over it, so it just cycles through all the animations over and over until i move the mouse away.
here's my code
private void OnMouseOver()
{
if (buttonSelected == false)
{
myAnimator.SetBool("IsSelected", true);
buttonSelected = true;
}
else
{
return;
}
}
private void OnMouseExit()
{
if (buttonSelected == true)
{
myAnimator.SetBool("IsSelected", false);
buttonSelected = false;
}
else
{
return;
}
}
,
okay, I found out that the problem is that On$$anonymous$$ouseExit is triggering even though I'm still touching the collider... I have no Idea how to fix this
Answer by indicidian · Jun 07, 2019 at 06:19 PM
well, I figured out a fix. rather than use the OnMouseOver and Exit methods, i changed them to two public methods and used the event trigger component with onPointerEnter and OnPointerExit
Your answer
Follow this Question
Related Questions
How do I modify animation parameters from script (C#) 1 Answer
Logic for a lot of animations 0 Answers
Movement and Jump with animator 0 Answers
When I run this code Unity crashes(ANIMATOR RELATED) 0 Answers