Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Working with the new Input System, and wondering if I'm going about it the wrong way.

Discussion in 'Input System' started by technano, Mar 18, 2021.

  1. technano


    Jan 13, 2016
    Hello everyone, I'm trying to get my character controller to work with the new Input System and I'm running into issues for jumping input for my player.

    I've tried looking around everywhere for solutions, but every solution goes about it in a different why than I am. The thing is, is that I like the way I've got my code set up and I really want to go about things this way, but I'm starting to think I'm going to have to refactor it all to get it to work.

    So this is the structure I have right now. I have an InputManager class, and this is the relevant code here:

    private void Awake()
    inputActions = new InputActions();
    inputActions.PlayerControls.Jump.performed += Jump_performed;
    inputActions.PlayerControls.Jump.canceled += Jump_performed;
    private void Jump_performed(InputAction.CallbackContext ctx)
    _isJumping = ctx.ReadValueAsButton();

    After this I have a PlayerLocomotion Class that takes the input of the player and does something with it here:

    public void HandleAllMovement()
    if (im.IsJumping)

    public void Jumping()
    //Do the jump stuff.

    And Finally I have a PlayerManager class to have all components of the player controlled under one class:

    private void FixedUpdate()

    My issue is that whenever my jump input is true the fixedUpdate calls it a bunch of times. I'm not sure how to constantly check if the input is happening but also only call the method once.

    Should I change it so that the jumping() method is happening in the inputManager? Or is there a way to have this structure and still get the same results?