Hello, hopefully you can help me and thank you if you try:
As you can see above when pressing W/using the Left Stick to go up, the transition takes place, but it freezes on the first frame and it stays exactly as you see it in the screenshot (the progress bar for walk_up).
Apparently it kinda lets the animation work if I check the Exit Time and Transition Duration, but I always unchecked those so I don’t have that delay in between moving directions.
Below is my code, using a basic movement script all worked fine, but trying to make an android game I redid it and now I have this annoying issue.
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerMovement : MonoBehaviour
{
public float speed = 5f;
public Rigidbody2D rb;
public Animator anim;
[SerializeField] private InputActionReference moveActionToUse;
[SerializeField] private float deadZone = 0.1f; // Deadzone pentru gamepad
private Vector2 moveDirection;
void Update()
{
moveDirection = moveActionToUse.action.ReadValue<Vector2>(); // Citim input-ul o singura data
// Aplicam deadzone pentru miscarile mici
if (moveDirection.magnitude < deadZone)
moveDirection = Vector2.zero;
UpdateAnimation();
}
void FixedUpdate()
{
if (moveDirection.sqrMagnitude > 0.01f)
rb.linearVelocity = moveDirection * speed;
else
rb.linearVelocity = Vector2.zero; // Opreste miscarea cand se opreste
}
void UpdateAnimation()
{
bool isMoving = moveDirection.sqrMagnitude > 0.01f;
anim.SetBool("IsMoving", isMoving); // se misca sau nu
if (isMoving)
{
// labareala pt gamepad
string direction = Mathf.Abs(moveDirection.x) > Mathf.Abs(moveDirection.y)
? (moveDirection.x > 0 ? "MoveRight" : "MoveLeft")
: (moveDirection.y > 0 ? "MoveUp" : "MoveDown");
anim.SetTrigger(direction); // pt. animatii
}
}
}