I’m working on a local multiplayer update for a game I recently released, and I want to stick with Unity’s Input System (the new one, not the old Input Manager). I’m using the PlayerInput and PlayerInputManager components. Originally, I wrote out the code myself for handling actions, such as this:
inputActions.Character.Movement.performed += ctx =>
{
if(cha.canMove)
{
InputControlManager.SetInputValue("Horizontal", ctx.ReadValue<Vector2>().x);
//set horizontal to regular input axis
horizontal = InputControlManager.GetInputValue("Horizontal");
}
else
{
horizontal = 0;
}
};
The above code worked just fine. However, when I started working with the PlayerInput class, I wrote them out like this:
public void OnMovement(InputAction.CallbackContext ctx)
{
CUGDebug.PrintNormal("PlayerCharacterInput:OnPlayerMovement()");
if (cha.canMove)
{
InputControlManager.SetInputValue("Horizontal", ctx.ReadValue<Vector2>().x);
//set horizontal to regular input axis
horizontal = InputControlManager.GetInputValue("Horizontal");
}
else
{
horizontal = 0;
}
}
I would set the PlayerInput to detect Unity events and attach my events to them. During runtime, input is being detected, but my characters aren’t moving. It’s not even calling the CUGDebug.PrintNormal (my version of Debug.Log) line. Is there a fix for this? Any help would be much appreciated.
Input System package version: 1.3.0
Unity version: 2020.1.15f1