- Home /
Local Multiplayer with new Input System problems
Hello everyone! I'm banging my head on a couple of problems on my local multiplayer project. The current problem is I cannot read input from a controller, and there is a weird bug when spawning new players.
This is how my Input Actions asset is set up. (Note: The controllers are set up correctly and the unity debugger shows all joysticks and buttons work)
This is how my Player Input Manager is set up:
The player input of the prefab i'm trying to spawn has the input actions asset I showed before, as well as the player's camera and the scheme set to PS4 and the default map as Movement.
That prefab has a simple script as well:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerInputManager : MonoBehaviour
{
public static Vector2 LeftJoystick;
public static Vector2 RightJoystick;
public static bool JumpButton;
private void OnMove(InputValue value) {
Debug.Log("Moving!");
}
}
The purpose of this script is to print the message whenever the OnMove function is called (The behavior in the player input is set to Send messages) but I run into a couple of problems:
When the object spawns, the Input Actions field inside the Player Input component is empty, and does not have the PS4 settings I associated with it on the prefab.
Sometimes after editing the prefab the players will not spawn no matter the button I press, so then i add the prefab to the scene, run it, delete the prefab from the scene and the players start spawning once again after pressing the buttons on my PS4 controller.
There are no prints on the console whenever I move the joystick on my controller, the function isn't running at all.
What have I tried:
Invoking unity events instead of sending messages, as well as broadcasting messages and invoking C# events.
Making a whole new unity project and bringing all of my assets there and reinstalling the new input system and setting everything up again.
Using context.performed as in this brackeys tutorial https://www.youtube.com/watch?v=p-3S73MaDP8 , which made the controller work perfectly, but when I spawned other players they were all controlled by the same controller, so this doesn't work for local multiplayer.
I've watched tens of tutorials and tried everything to fix this problem but sadly there is little documentation of the new input system and local multiplayer. I would really really REALLY appreciate someone's help, this problem has been insane and has stopped completely the progress in my project, thank you so much for reading this and your help everyone, I wish you all the best! <3
Answer by Quazaar_studios · Jan 22, 2021 at 11:44 PM
Update: Tried using another controller from an example on my player and that worked flawlessly, but when I use the new one I made it doesn't work, any ideas? Thanks everyone!