#Player Combat Issues

1 messages · Page 1 of 1 (latest)

austere herald
#

I’m running into a weird issue with Unity’s New Input System:

My Attack action (bound to LMB) fires once automatically when the game starts
After that, I can’t trigger attacks anymore
Attack plays an Animator trigger (combo-based system), Attack timing is managed using cooldown (attackTimer) and animation events (OnAttackHit, EndAttack) and my Animation state uses a StateMachineBehaviour to call EndAttack() on exit.
.started only fires once, and IsPressed() returns true constantly
Input logs confirm clicks are happening, but the action won’t re-trigger

Has anyone seen the Input System get stuck in a “pressed” state like this? Could this be a mouse binding issue, input not resetting on enable, or something with editor/game window focus?

#
    void Awake()
    {
        playerCombat = GetComponent<PlayerCombat>();
        inputActions = new GameInputs();
        inputActions.Player.Move.performed += ctx => moveInput = ctx.ReadValue<Vector2>();
        inputActions.Player.Move.canceled += _ => moveInput = Vector2.zero;
        inputActions.Player.Look.performed += ctx =>
        {
            float raw = ctx.ReadValue<Vector2>().x;
            lookInput = Mathf.Clamp(raw, -maxTurnSpeed, maxTurnSpeed);
        };
        inputActions.Player.Look.canceled += _ => lookInput = 0f;

        inputActions.Player.Sprint.performed += _ => isSprinting = true;
        inputActions.Player.Sprint.canceled += _ => isSprinting = false;

        inputActions.Player.LockOn.performed += _ => ToggleLockOn();
    }

    void OnEnable()
    {
        inputActions.Enable();
        inputActions.Player.Attack.performed += OnAttack;
    }

    void OnDisable()
    {
        inputActions.Player.Attack.performed -= OnAttack;
        inputActions.Disable();
    }

    void Start()
    {
        controller = GetComponent<CharacterController>();
        mainCamera = Camera.main;
        Cursor.lockState = CursorLockMode.Locked;
    }

    void Update()
    {
        if (IsLockedOn)
        {
            if (LockOnTarget == null || !LockOnTarget.gameObject.activeInHierarchy ||
                Vector3.Distance(transform.position, LockOnTarget.position) > lockOnRange * 1.2f)
            {
                ReleaseLockOn();
            }
            else
            {
                UpdateLockOnMovement();
            }
        }
        else
        {
            UpdateOrientation();
            Move();
        }

    }

    private void OnAttack(InputAction.CallbackContext ctx)
    {
        if (requireRelease) return;
        Debug.Log("Attack INPUT TRIGGERED");
        HandleAttack();
    }

    private void HandleAttack()
    {
        Debug.Log("Calling Try Attack...");
        playerCombat?.TryAttack();
    }
stark parcel
#

Also not clear which code is printing that log from your screenshot?