#Non-looping animation firing twice
1 messages · Page 1 of 1 (latest)
public class Succubus : BoxPlayer
{
private Vector2 _moveDirection;
private PlayerInput playerInput;
[SerializeField] private float speed = 5f;
public InputActionReference move;
public InputActionReference attack;
public InputActionReference jump;
new void Start()
{
base.Start();
playerInput = GetComponent<PlayerInput>();
playerInput.SwitchCurrentActionMap("Player");
if (move != null && move.action != null)
{
move.action.performed += OnMovePerformed;
move.action.canceled += OnMoveCanceled; // Optional: Handle stopping movement
}
if (attack != null && attack.action != null)
{
attack.action.performed += context => OnAttack();
}
if (jump != null && jump.action != null)
{
jump.action.performed += context => OnJump(); // Use a separate method for jump
}
}
new void Update()
{
base.Update();
if(MoveVector().x < 0)
{
SpriteRenderer().flipX = true;
}
else if (MoveVector().x > 0)
{
SpriteRenderer().flipX = false;
}
if(_moveDirection.x != 0 && !Animator().GetBool(State.airbourne))
{
Animator().SetBool("walking", true);
RigidBody2D().linearVelocityX = _moveDirection.x * speed;
}
else if(_moveDirection.x == 0 && !Animator().GetBool("airbourne"))
{
Animator().SetBool("walking", false);
}
}
...
public void Attack()
{
Animator().SetTrigger(State.attack);
}
public void OnAttack()
{
if(!Airbourne())
{
RigidBody2D().linearVelocityX = 0;
}
Attack();
}
- How is your Attack input action configured?
- How is your animatior state machine configured?
Here is the Input mapped.
Player Input:
oh, I wonder if it is firing twice because of that
I want to see the action configuration, not the binding
and yes it looks like you have subscribed the method twice
once in your code, once on the PlayerInput component
yup it looks like that was the culprit.
Could you help me understand what you are asking for by "configuration"?
The action properties?
yep
it's a moot point now
but if it was set to "Pass Through", for example, that could have been another reason.
for sure. I wanted to make sure I could get the info people want who are trying to help me in future, you know?