- Home /
(LOCAL) Multiplayer controls?
Hey guys! I'm making a small game for our bi-monthly LAN parties, but this is my first attempt at a Multiplayer game, so I'm not too sure how to take each player's input
My idea was to add a "p1" at the beginning of the names for the current "horizontal" and "vertical", then add a p2, p3, and p4 version of both, then in the code, say:
if(p1 horizontal != 0 OR p1 vertical != 0)
move p1;
else if (p2....) etc
However that creates a lot more checking for EVERY frame, in update and Idk if that will be too much, if it would be okay but there's a more optimal way that I'm not thinking of, or if perhaps there is already set code/features to handle this situation that I just don't know about yet!
So... what's the best way to handle local multiplayer (4-person max) up/down and left/right (4way) movement controls?
Answer by ragnaros100 · Oct 27, 2013 at 09:32 AM
If you're using controllers you can use unitys built in Joystick1, 2, 3 and 4 Inputs and check for that. I would recomend xinput if you're using xbox 360 controllers.
If you're not using controllers, but are using keyboard(s). You should do what you are doing now. Unity's a powerfull tool and a couple of for loops wont crash it.
Joistick 1,2,3, and 4 Inputs are perfect :D How does Unity go about deciding which one is #1, 2, 3, and 4? Is it the order they're plugged in, certain ports, or wha?
Your answer
![](https://koobas.hobune.stream/wayback/20220613120711im_/https://answers.unity.com/themes/thub/images/avi.jpg)