Hello, again unity community I come to you with a problem that has stalled our development for about a day and half. Our Player uncontrollably won’t stop cycling through he’s animation states over and over again in a endless loop. Even though the parameters for his transitions in mecanum haven’t been meant. Below I have posted a breakdown of the problem.
Breakdown from the editor:
The player’s animations are cycling like this uncontrollably:
Besides this the print statements in my code, Just won’t stop printing over and over again. When they should be printing only once per player input. Another symptom to the problem I guess.
My profiler also showed that my function (to set the animation’s parameter) is being called over and over again when there is no input from the player:
Code Breakdown:
From SwimmingTurtlePlayer to TurtleBack (TurtleBack is a Blend tree between to clips) we were using a float parameter for speed (note that the player is moving backwards on the x-axis in the negative direction);
Code:
public Animator TurtlePlayer;
public Rigidbody2D Turtle;
public Vector2 velocity;
public Vector2 backVelocity;
public float BackVelocity;
public float Velocity;
if (Input.GetKey (KeyCode.Mouse2)) {
Turtle.MovePosition (Turtle.position - backVelocity *Time.fixedDeltaTime);
//move player's rigid body backwards.
TurtlePlayer.SetFloat ("TurtleSpeed",BackVelocity);
//set float parameter for player's speed.
Invoke("StartReverseTrans", 3); // invoke new function to give player time to move before starting the coroutine.
}
Then from TurtleBack to TurtleBackToNormal we are using a bool parameter called TurtleSwimNow that is set equal to true.
Code:
void StartReverseTrans()
{
TurtlePlayer.SetBool("TurtleSwimNow",true); // set player's animation bool parameter.
Turtle.velocity = Vector2.zero; // set player's speed to zero as a reset. Speed will change upon player's new input.
print ("I'm A transitioning Turtle");
StartCoroutine(TurtleSwimNow()); //start coroutine.
}
Finally, from TurtleBackToNormal to SwimmingTurtlePlayer the bool parameter TurtleSwimNow is set to false.
Code:
IEnumerator TurtleSwimNow ()
{
TurtlePlayer.SetBool ("TurtleSwimNow", true); // set player's animation bool parameter.
yield return new WaitForSeconds (2f);
TurtlePlayer.SetBool ("TurtleSwimNow", false); // set player's animation bool parameter. Player then returns to default animation in mecanum.
print ("I'm Swimming Normally Now");
}
Can someone help us, we will appreciate it.











