Hey all, I an dipping my toe in the new input system. After a tutorial, I have things working, but I am running into an issue where my idle and walk animations are not behaving as I should. When I trigger from walk to idle and vice versa, the other fires at the end and I am not sure why. Below is my movement code:
public class Succubus : MonoBehaviour
{
BoxCollider2D collidr;
Rigidbody2D rb;
Animator animator;
Vector2 _moveDirection;
...
public InputActionReference move;
public PlayerData data;
void Start()
{
...
collidr = GetComponent<BoxCollider2D>();
rb = GetComponent<Rigidbody2D>();
animator = GetComponent<Animator>();
data.HP = data.MaxHP;
}
void Update()
{
_moveDirection = move.action.ReadValue<Vector2>();
}
void FixedUpdate()
{
if(_moveDirection.x != 0)
{
spriteRenderer.flipX = _moveDirection.x < 0;
animator.SetTrigger(Trigger.walk_);
rb.linearVelocityX = _moveDirection.x * data.velocity; // data.velocity = 7
}
else
{
rb.linearVelocityX = 0;
animator.SetTrigger(Trigger.idle_);
}
}
void OnEnable()
{
...
move.action.started += Move;
}
void OnDisable()
{
...
move.action.started -= Move;
}
void Move(InputAction.CallbackContext obj)
{
animator.SetTrigger(Trigger.walk_);
}
...
}