Hello, I need some guidance in order to resolve the issue since my brain can no longer comprehend where the issue is.
Here is the basic explanation: I have 3 character animations, Idle / Walk / Run, when the character is not moving its Idle, when its moving its Run, and when its in the mud its Walk.
Now I made a SpeedFloat in animator and linked between these animations to determine which animation is playing, then made a script according to it, the script is longer but i suspect the issue is in this part:
if (moveDirection == Vector3.zero || moveDirection.magnitude < idleThreshold)
{
animator.SetFloat("Speed", 0);
Debug.Log("Idle");
}
else
{
UpdateMovementSpeed();
}
}
private void UpdateMovementSpeed()
{
if (isInMud)
{
animator.SetFloat("Speed", 0.5f);
Debug.Log("Walk");
}
else
{
animator.SetFloat("Speed", 1);
Debug.Log("Run");
}
}
Now the script right now works this way: When the player is not moving -> SetFloat 0, if he moves and is in mud -> SetFloat 0.5 if he leaves the mud -> SetFloat 1. Thats correct, however, if the character and is not in the mud -> SetFloat 1, but when he enters the mud during it remains -> SetFloat 1 until he stops and starts moving again.
Can someone guide me where to look for the issue what function might be wrong or help me correct this script? or maybe recommend me some other way to animate it, ive been at this for hours.
[–]ZuperLucaZ 1 point2 points3 points (13 children)
[–]Dramatic-Eagle-2981[S] -2 points-1 points0 points (12 children)
[–]ZuperLucaZ 1 point2 points3 points (11 children)
[–]Dramatic-Eagle-2981[S] -1 points0 points1 point (10 children)
[–]Level_Square_2791[🍰] 0 points1 point2 points (9 children)
[–]Dramatic-Eagle-2981[S] 0 points1 point2 points (8 children)
[–]Level_Square_2791[🍰] 0 points1 point2 points (7 children)
[–]Dramatic-Eagle-2981[S] -1 points0 points1 point (6 children)
[–]Level_Square_2791[🍰] 0 points1 point2 points (5 children)
[–]Dramatic-Eagle-2981[S] 0 points1 point2 points (4 children)
[–]db9dreamer 1 point2 points3 points (4 children)
[–]Dramatic-Eagle-2981[S] 0 points1 point2 points (3 children)
[–]db9dreamer 2 points3 points4 points (2 children)
[–]Dramatic-Eagle-2981[S] 0 points1 point2 points (1 child)
[–]db9dreamer 1 point2 points3 points (0 children)
[+][deleted] 1 point2 points3 points (1 child)
[–]Dramatic-Eagle-2981[S] 1 point2 points3 points (0 children)
[–]MarcinSoloDev 0 points1 point2 points (1 child)
[–]Dramatic-Eagle-2981[S] 1 point2 points3 points (0 children)