Tying to learn the new input system but very confusing. I just want to get a simple ReadValue to work.
Set up my Input Actions map as I want to
And in my code I got Jump to work, very simple but read input value no luck. How would I go about doing this?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class S_PlayerInputs : MonoBehaviour
{
public PlayerInput playerInput;
public GameObject ownPlayer;
Rigidbody2D rigiBody;
Vector2 moveDirection = Vector2.zero;
// Start is called before the first frame update
void Start()
{
rigiBody = ownPlayer.GetComponent<Rigidbody2D>();
Debug.Log(playerInput.currentActionMap);
playerInput = GetComponent<PlayerInput>();
}
// Update is called once per frame
void FixedUpdate()
{
Debug.Log(playerInput.Movement.ReadValue<Vector>);
}
void OnJump()
{
// Jump !!
rigiBody.velocity = new Vector2(0, 10);
Debug.Log("Player jumped!");
}
void OnMovement()
{
//Debug.Log("A or D pressed");
//moveDirection = playerInput.ReadValue<>;
}
}
Tried doing a simpe “Debug.Log(playerInput.Movement.ReadValue);” that makes sense in my head but no luck.
Thanks. Would appreciate help.