How to acces or get float work on Parameter using new Input System

im Using Float moveX/moveY, because i want to make a blend animation.
if thare is a better way to do it maybe, i need some help because im still bit confused using this new input system

here the CODE


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

[RequireComponent(typeof(CharacterController))]
[RequireComponent(typeof(Animator))]
public class pInputSystem : MonoBehaviour
{
    [Header("Object Reference")]
    [SerializeField]
    private InputActionReference MovementControl;
    [SerializeField]
    private InputActionReference JumpControl;
    
    [Header("Variable")]
    [Range(0,5)]
    [SerializeField]
    private float playerSpeed;
    [Range(0,5)]
    [SerializeField]
    private float jumpHeight;
    [Range(0, -10)]
    [SerializeField]
    private float gravityValue;
    [Range(0,5)]
    [SerializeField]
    private float rotationSpeed;
    
    private float moveX , moveY;
    private Animator anim;
    private CharacterController pCharacter;
    private PlayerInput pInput;
    private CInput pInputActions; 
    private Vector3 pVelocity;
    private Transform cameraMain;
    private bool GroundedPlayer;

    private void OnEnable() {
        MovementControl.action.Enable();
        JumpControl.action.Enable();
        pInputActions.Player.Enable();

    }

    private void OnDisable() {
        MovementControl.action.Disable();
        JumpControl.action.Disable();
        pInputActions.Player.Disable();
    }

    private void Awake() {
        anim = GetComponent<Animator>();
        pCharacter = GetComponent<CharacterController>();
        pInput = GetComponent<PlayerInput>();
        cameraMain = Camera.main.transform;
        pInputActions = new CInput();
    }

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        pCharacterControler();
        pCharacterAnimation();
    }
    private void FixedUpdate() {

    }

    private void pCharacterControler(){
        GroundedPlayer = pCharacter.isGrounded;

        if(GroundedPlayer && pVelocity.y < 0){
            pVelocity.y = 0f; 
        }

        Vector2 movement = MovementControl.action.ReadValue<Vector2>();
        Vector3 move = new Vector3(movement.x, 0f, movement.y);
        move = cameraMain.forward * move.z + cameraMain.transform.right * move.x;
        move.y = 0f;
        pCharacter.Move(move * Time.deltaTime * playerSpeed );

        if (JumpControl.action.triggered && GroundedPlayer){
            pVelocity.y += Mathf.Sqrt(jumpHeight * -3f * gravityValue);
        }

        pVelocity.y += gravityValue * Time.deltaTime;
        pCharacter.Move(pVelocity * Time.deltaTime);

        if (movement != Vector2.zero){
            float targetAngle = Mathf.Atan2(movement.x, movement.y) * Mathf.Rad2Deg + cameraMain.transform.eulerAngles.y;
            Quaternion rotation = Quaternion.Euler(0f, targetAngle, 0f);
            transform.rotation = Quaternion.Lerp(transform.rotation, rotation, Time.deltaTime * rotationSpeed);
        }

    }

    private void pCharacterAnimation(){
        
    }
 
}

I don’t think I understand what you mean by getting a float from the new input system. You are already getting a vector 2 from the InputActionReference called MovementControl. And a vector 2 is just two floats put into one variable. So if you want to get the X or Y axis as a float just access them from the vector 2.


Also, if you want to learn more about the new input system, I would strongly recommend trying out the sample projects that Unity provides in the package manager. You can find the sample projects by looking up the Input System in the package manager under the Unity registry packages. And once you are there, you will see a drop-down list labelled Samples, and there are so many different examples of how to use the new input system.