Search Unity

Multiple Playstation 3 Controllers on Mac OS for 2 Player Split Screen

Discussion in 'Editor & General Support' started by jshmanz, Oct 25, 2010.

  1. jshmanz

    jshmanz

    Joined:
    Oct 25, 2010
    Posts:
    5
    Hi, I'm a grad student working on a project with a partner in class to create a 2 player cooperative game. Our first play test occurred before I could figure out how to make controllers work properly and separately (I was tagging things correctly as far as I can tell - joystick 1 and joystick 2) and if I remapped the keys to keys on the keyboard everything worked right. But the controllers seemed to do the same thing for both players. I think I have figured out the issue - I have been using Playstation 3 controllers which work all right (the buttons do, the analog sticks I'm still having some confusion with but think a classmate gave me an idea that I must implement still) but do not establish themselves as controller 1 and controller 2, therefore, it seems, while I can map the x button to make player 1 jump, for example, both controllers can cause player 1 to jump if the x button is pressed and if the circle button is for player 2 to jump, both controllers can cause player 2 to jump if the circle button is pressed. I have talked to everyone I know that knows anything about Unity and nobody has had much experience with multiple controllers and therefore don't know how to help me out.
    Should I be giving up my PS3 controllers and finding other controllers? And which controllers will work on my mac (and my partner's pc) when using 2 controllers?
    I asked this question a few days ago on Unity Answers because I couldn't properly register on this forum for some reason. I have since worked on the Windows side of my mac and found drivers that can separate controller 1 and controller 2. The problem is, now I still can't figure out how to map these properly even though I've played around with the customization on this program (MotioninJoy). I have made a few things occur, largely by accident, but unfortunately even though the controllers are separaretly recognized, I can STILL control both players when I do some things. It also sometimes will make things happen (input from either controller) just for player 1.
    I've now spent weeks trying to make this happen properly and feel as though perhaps networking this game with zero networking experience might have been easier!! I would very much appreciate anyone's input or advice.
    Thanks for reading my troubles and thanks in advance for any help.
     
  2. Jesse Anders

    Jesse Anders

    Joined:
    Apr 5, 2008
    Posts:
    2,857
    This might be overly obvious, but make sure that in your axis setup in the input manager you have the axes assigned to specific joysticks, rather than accepting input from all joysticks. (This would be under 'Joy Num'.)

    Again, that's a fairly obvious guess, but it's the first thing that comes to mind. If that doesn't help, you might considerer posting a screenshot of the setup for one of your axes. (Unless of course someone else recognizes the problem and helps you straighten it out before then.)
     
  3. jshmanz

    jshmanz

    Joined:
    Oct 25, 2010
    Posts:
    5
    No, I've repeatedly checked that issue. They are definitely labeled correctly in the Input Manager as "joystick 1" and "joystick 2" and the buttons are being assigned as "joystick button 1", etc. I've made little maps for myself on which buttons are which number. I even changed things around on the PC side when they were not the same. I can manually change the input before the game starts, but then they also control both players when I use the same buttons for each player (Player 1 uses x to jump and so does Player 2, so both do it no matter which controller presses it). If I assigned triangle to player 1, only player 1 jumps. Can't be the same configuration for both controllers though and I need to use most of the buttons so that won't work as a work-around. I can post a screenshot later today after I reset some things (I ended up deleting my driver last night in an attempt to add an additional driver). I am also still not certain how to take a screenshot on the windows side.
     
  4. Jesse Anders

    Jesse Anders

    Joined:
    Apr 5, 2008
    Posts:
    2,857
    The 'Joy Num' field doesn't apply to buttons. IIRC, the button descriptor 'joystick button 0' refers to button 0 from any joystick. Try instead using 'joystick 1 button 0', 'joystick 2 button 0', etc. (I think the joystick numbers are one-based and the button indices are zero-based, but you might need to double-check that.)
     
  5. GlitchInTheMatrix

    GlitchInTheMatrix

    Joined:
    Apr 12, 2010
    Posts:
    285
    Last edited: Oct 26, 2010
  6. jshmanz

    jshmanz

    Joined:
    Oct 25, 2010
    Posts:
    5
    ratonmalo- Yes that was the only problem - the multiple controllers. I have since managed a work around though I'm still open to suggestions on improving it. I have made everything remain "Get Motion from all Joysticks" and just used Key or Mouse Button and kept my original keyboard-only controls and used MotioninJoy to take the input from the controllers and output the corresponding keys down (Player 1 is set to WASD and so up, down, left, and right on the player 1 controller will create a WASD input). I cannot figure out how to separate them to be used as gamepad buttons, nor how to separate them so I can use the thumbsticks without controlling both players. I know how to do this properly (without booting on the PC side and using the third party driver) in Unity on the mac side of my macbook pro, but cannot make this happen correctly with two controllers.

    Jesse - "joystick 1 button 0" appears to throw errors. I believe the correct phrasing is "joystick button 0" and that has always worked properly with just one controller in a one player scenario. Several weeks ago I overcame that frustration when I realized I'd been writing it the other way and that was what was causing the error. I have now been working on controllers for a multiplayer split screen with 2 Playstation 3 controllers for about 5 or 6 weeks... if the best I can do is what I have so far, at least it's working. If any inspiration can be offered, I'd still really love to have the thumbsticks working by our second play test. The first one's biggest complaint was using the keyboard with no mouse. I really just wanted to interrupt the play testers and tell them I know and had been working on it for 3 weeks at that point!

    Any further help would be appreciated. But, at least, rest assured I made *something* happen. -.- Even if not exactly what I have been working towards. Thank you for your input already.
     
  7. Jesse Anders

    Jesse Anders

    Joined:
    Apr 5, 2008
    Posts:
    2,857
    I haven't had any such problems with these names. Can you post the errors you're getting?

    No, the correct phrasing is 'joystick button 0' if you want to respond to button 0 on any controller, and 'joystick N button 0' if you want to respond to button 0 on a specific controller.

    Other threads that discuss this:

    Thread 1
    Thread 2
    Thread 3

    Also see the documentation.

    Granted, I think the documentation has some typos/errors, but notice at the end of the list labeled 'Joystick Buttons (from a specific joystick)', it says 'joystick 1 button 0'.

    Yes, of course it does; 'joystick button 0' means button 0 from any joystick, so it should be expected to work correctly with only one controller.

    I only have one controller to test with, so there is a possibility that there's something I'm missing here. But, everything I've read on the forums has indicated to me that 'joystick button Y' refers to button Y on any controller, and 'joystick X button Y' refers to button Y on controller X.

    Rather than assuming this is incorrect, I'd recommend looking into it a bit further and/or posting your errors so we can take a look.
     
  8. jshmanz

    jshmanz

    Joined:
    Oct 25, 2010
    Posts:
    5
    Okay, I understand what you're saying now. You're probably exactly right, except that then I can't move forward figuring out how to address the separate controllers because when I do say joystick 1 button 0, nothing happens anywhere in any way I expect. I'm not getting errors for it anymore, I may have mistaken some other errors I was creating for errors related to this. Just nothing happens. It doesn't seem to be finding joystick 1 or joystick 2 to take button input from.

    I managed to make things work still with the third party key stroke input, but it's not really as good as if it just worked *correctly* without having to use other stuff. I'd have really liked to get the thumbsticks working before our next play test which is in about a week and a half now. I'm still having some issues related to having two players in one space (right now I've got an elevator that either they're both stuck to, only improperly when just 1 at a time should be). On the bright side, half of our game is now functioning absolutely in the correct manner it was intended to function - all other triggers work when both players are in the correct place so no one can get locked behind a door, no one can cheat and hold open a door by pressing a different switch while the other player is near another switch somewhere else, etc.

    After I fix this elevator, which I've now been increasingly frustrated with for the past two days, I will make a fresh new attempt at the controllers and post actual screenshots of what I'm doing. I keep promising those and not doing it because I keep dismantling my work in an attempt to fix it.

    Thanks for your responses! You've certainly explained some things to me that I wasn't understanding and given me some new inspiration as to how to proceed.
     
  9. Jesse Anders

    Jesse Anders

    Joined:
    Apr 5, 2008
    Posts:
    2,857
    Well, I wish I had a couple of PS3 controllers handy so I could test it out :) But yeah, if you're still stuck on this, you might post some code and/or screenshots showing how you've got things set up.

    A couple of other things you might try:

    1. In the rendering/input configuration window that (optionally) opens when you launch the standalone, try assigning different buttons from the controllers to some controls. See if all of them register, or only some of them register.

    2. Or, write a script that runs through every 'joystick X button Y' combination and displays (e.g. as debug output) whether any joystick button is currently down. Then (as above) check and see if all buttons are registering, or only some buttons are registering.

    (Maybe you've already done something to this effect, but if not, it might be worth trying.)
     
  10. jshmanz

    jshmanz

    Joined:
    Oct 25, 2010
    Posts:
    5
    I have a "map" I've made of what each button means on one controller. I have tried in the past to do what I think you're suggesting and found that some things "work" but are still working from both controllers. But, armed with new information, I might be able to better figure out what's actually happening. I have no idea how to write a script for the output, though. I've only been using Unity since September and I am not a programmer so... sometimes I find it miraculous that I've made anything happen at all. Maybe you could give me a better idea as to how I'd start to write a script for that? Maybe some sort of update function that just outputs a Debug log to say something like "button pressed"? I guess that's what you're saying, but I'm not sure. And the input config window I have attempted on the pc side only which now is seeming like a mistake so I think I'll try that first on the mac side and check out. Maybe it can distinguish the controllers natively and I'm just too stupid to figure it out, so it seems worth another try. :)
     
  11. Jesse Anders

    Jesse Anders

    Joined:
    Apr 5, 2008
    Posts:
    2,857
    Ok, I'll give it a go (C# script):

    Code (csharp):
    1. void Update()
    2. {
    3.     bool buttonPressed = false;
    4.     for (int i = 1; i <= 4; ++i) {
    5.         for (int j = 0; j < 20; ++j) {
    6.             string buttonName = "joystick " + i + " button " + j;
    7.             if (Input.GetKey(buttonName)) {
    8.                 Debug.Log(buttonName);
    9.                 buttonPressed = true;
    10.             }
    11.         }
    12.     }
    13.     if (!buttonPressed) {
    14.         Debug.Log("none");
    15.     }
    16. }
    That is untested and off the top of my head, but you might drop it in and give it a try. If there are obvious errors they'll probably be pointed out by other posters, but if you get any compiler errors or it doesn't work as expected, let me know.

    (Note that the intended usage is to press one button on one controller at a time, go through all the buttons, and see which ones register and which, if any, do not.)
     
  12. Solethia

    Solethia

    Joined:
    May 19, 2013
    Posts:
    1
    I had the same problem with my PS3 Controllers, the solution is in the inputManager (edit -> project preferences -> inputManager) where each button will have a value called 'Positive Button', that should be set to 'joystick {i} button {f}'. Where {i} is the joystick number and {f} is the button number. IT IS NOT enough to set the 'Joy Num' value to the correct Joystick, that apparently only works for axis.

    Hope this helps.

    Kind Regards
    Daniel Møgelgaard Pedersen