Only getting an output of 0.01 or 0?

Currently working on a simple game, but ive encountered a problem. Once I tried to implement jumping everything stopped working and i cant figure out why.
Heres the script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

public class characterController_ : MonoBehaviour
{
    PlayerInput playerInput;
    CharacterController characterController;

    Vector2 currentMovementInput;
    Vector3 currentMovement;
    Vector3 currentRunMovement;

    bool isMovementPressed;
    bool isRunPressed;

    public float rotationFactorPerFrame = 20f;
    public float runMultiplier = 5f;
    public float walkMultiplier = 3f;

    void Awake()
    {
        playerInput = new PlayerInput();
        characterController = GetComponent<CharacterController>();

        playerInput.Game_DefaultPlayer.Move.started += OnMovementInput;
        playerInput.Game_DefaultPlayer.Move.canceled += OnMovementInput;
        playerInput.Game_DefaultPlayer.Move.performed += OnMovementInput;
        playerInput.Game_DefaultPlayer.Run.started += OnRun;
        playerInput.Game_DefaultPlayer.Run.canceled += OnRun;
    }

    void OnRun(InputAction.CallbackContext context)
    {
        isRunPressed = context.ReadValueAsButton();
    }

    void HandleRotation()
    {
        Vector3 positionToLookAt;
     
        positionToLookAt.x = currentMovement.x;
        positionToLookAt.y = 0.0f;
        positionToLookAt.z = currentMovement.z;

        Quaternion currentRotation = transform.rotation ;

        if (isMovementPressed)
        {
            Quaternion targetRotation = Quaternion.LookRotation(positionToLookAt);
            transform.rotation = Quaternion.Slerp(currentRotation, targetRotation, rotationFactorPerFrame * Time.deltaTime);
        }
    }

    void OnMovementInput(InputAction.CallbackContext context)
    {
        currentMovementInput = context.ReadValue<Vector2>();
        currentMovement.x = currentMovementInput.x * walkMultiplier * Time.deltaTime;
        currentMovement.z = currentMovementInput.y * walkMultiplier * Time.deltaTime;
        currentRunMovement.x = currentMovementInput.x * runMultiplier * Time.deltaTime;
        currentRunMovement.z = currentMovementInput.y * runMultiplier * Time.deltaTime;
        isMovementPressed = currentMovementInput.x != 0 && currentMovementInput.y != 0;
    }

    void Update()
    {
        HandleRotation();

        if (isRunPressed)
        {
            characterController.Move(currentRunMovement * Time.deltaTime);
        }
        else
        {
            characterController.Move(currentMovement * Time.deltaTime);
        }
        Debug.Log(currentMovement);
    }

    void OnEnable()
    {
        playerInput.Game_DefaultPlayer.Enable();
    }

    void OnDisable()
    {
        playerInput.Game_DefaultPlayer.Disable();
    }
}

In the update function it logs the current movement, but when i give an input it gets set to 0.01, not 3 or 5 like it should. Even tried to add keyboard input to the action map, no input what so ever.
Anyone got an idea of what this could be?

You’re multiplying by Time.deltaTime in both the code that receives input and in Update.

2 Likes