I have heard that Unity can do multiplayer games that work on the same computer. Is this a minor scripting thing, a Unity easy thing, or a I’m gonna kill myself trying to figure it out thing? If it’s one of the first two, how do I do it?
Easy
All you do is create another camera for the other player and set how the camera renders on screen.
I belive the settings are the Normalized Viewport Rect in the camera’s inspector, 1 being full screen, .5 being half, etc.
Do a forum search for split-screen, multiple-cameras, etc, to be sure though. I remember a few topics about this.
-Jeremy
You can do multiplayer on one computer in Unity.
If you want to have the screen split, like left player looking at the left side of the screen and right player looking at the right side, take a look at the camera component and its view size parameters. Set up two (or more) cameras and have each one render to a different part of the screen.
If you want two players to use the same keyboard, check out the Input class, especially the GetKeyDown() method.
Thanks guys, that’s exactly what I was looking for.
I have one other question. Can Unity use a joystick or gamepad? If so, can it support multiple input devices for multiple players?
Of course it can. You can use up to 10 joysticks/gamepads at the same time.
Cool! Thanks for the help.
Now that I have more of a game to work with, and two gamepads, I have a new question. How do I set up the Input axes so that they will be gamepad-specific?
At the moment my axes do not differentiate between gamepads. I tried playing with the Joy Num setting on each axis, but haven’t been able to get it to do what I want. Where to I change that setting?
Also, I have three axes on my game controller, and I want to use both of the analog sticks (not the arrows), but one of the analog sticks is not axis 3 4 5 or 6 on the gamepad, so I can’t set it up in the input manager. Is there another way (maybe a script)?
EDIT: I found what the problem was - I just needed to use the X and Y axis for this, so ignore this question
Usually you just change from the GetMotionFromall joysticks to joystick 0 or joystick 1.
Ok, I’ll try playing with that a little more. Thanks!
Edit: It works! I just needed to switch my controllers to different USB plugs on the computer - they were both plugged into the monitor before, which is separate from the rest of the machine. I guess daisy-chaining doesn’t work so well…
I’ve been trying to do the same thing, but I’m having trouble getting the Xbox 360 Controller to control just one character. It’s currently controlling both at once.
How can I make the Xbox 360 Controller move only one of the characters?
I have a single fixed camera.
Both players are onscreen, and can be controller separately with the keyboard (P1 uses WASD, and P2 uses the arrow keys).
I’ve now made it so Joypad 1 can control P1. But when I press the buttons it also moved P2.
I’m using the InputManager, and I have MoveForwardsP1 set to joystick button 16 on Joy Num: Joystick 1, and I have MoveForwardsP2 set to joystick button 16 on Joy Num: Joystick 2.
So I don’t understand why both players move when I press joystick button 16 on Joystick 1. Shouldn’t it only move P1?