- Home /
Input System not executing Unity events
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
Answer by JJNCreator · May 19 at 02:15 PM
I figured it out. I had to assign an input device to each character.
Your answer
Follow this Question
Related Questions
New input system - package settings causes errors 0 Answers
When I press Control my character cant move? 1 Answer
Unity Input System Package Stick/Axis Deadzone if set as a processor not working 0 Answers
Changing Action Map from Script doesn't update in the Inspector 0 Answers
Add keyboard input in ClickToMove 0 Answers