however when the button is pressed (in our case the third mouse button), the animation keeps transitioning very fast over and over again, sometimes all 3 animations play at once. Then decides to work properly, which is when the button is pressed down or held down the character stays in the apporite (“TurtleBack”) state until the button is pressed again.
Howdy, I assume this code exists inside an Update function. With that information, the line KeyCode.Mouse2 is going to be evualated many, many times a second. More than likely, that is your problem. Consider using GetKeyDown instead. On that note, the code StartCoroutine (TurtleSwimReset(); will be called many times as well. This will start that coroutine many times a second and will probably cause many problems as well. Again, consider reworking your code so that you can use GetKeyDown instead.
While, we tested using get keydown and get keyup still the same results. Also we had some strange behavior, somehow the set bool for false was still being called even though I commented out the start coroutine. Leading into that infinite loop we keep seeing.
if (Input.GetKeyDown(KeyCode.Mouse2))
{
Debug.Log ("Start moving Turtle Backwards");
Turtle.MovePosition(Turtle.position - backVelocity * Time.unscaledDeltaTime);
//Debug.Log("player is moving backwards");
TurtlePlayer.SetFloat("TurtleSpeed",BackVelocity);
//Debug.Log("player's speed animation is set");
}
else if (Input.GetKeyUp(KeyCode.Mouse2))
{
TurtlePlayer.SetBool("TurtleSwimNow",true);
//print ("I'm A transitioning Turtle");
//StartCoroutine(TurtleSwimNow());
}