This is my first time using the Input System Package, so I have spent a while following tutorials and looking online for answers, but as far as I can tell I’m doing everything right with it and I’m still not getting any responses to key-presses.
Below are screenshots of how I have everything set up, hopefully this is everything needed to find the problem. If there’s something else that might help though, I could grab a screenshot and include it too.
I have tried a bunch of different things, and I can confirm that update is running, but as far as I can tell, neither Jump or Walk work, and I have no idea why.
Any help would be appreciated with this, thank you!
I don’t see you connecting up the Walk() delegate anywhere (but images are always the worst way to see code; for proper code posting, use the forum text box link), or enabling the InputAction / Map… are you sure you went through a good tutorial? The ones on Unity should be your checklist…
I’m not quite sure what you mean about connecting a delegate or enabling the InputAction.
Idk if this does answer that, but I have my Walk() code called by the PlayerInput component via Unity Event whenever the associated keys (left and right arrow keys) are pressed, and I have the Input Action Asset selected within the same component.
As for the code, here it is pasted in:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerMovement : MonoBehaviour
{
float moveAmount;
public void Walk(InputAction.CallbackContext context)
{
// Walk in direction pressed
moveAmount = context.ReadValue<float>();
print(moveAmount);
}
public void Jump()
{
print("Jump");
}
public void Update()
{
print(moveAmount);
gameObject.transform.position = new Vector2(gameObject.transform.position.x + moveAmount, gameObject.transform.position.y);
}
}