Unity Community


Results 1 to 11 of 11

  1. Location
    Ontario
    Posts
    19

    [Need Help] Xbox 360/PC controller Triggers

    I'm using an xbox/pc controller to Aim with one button, and then shoot with another button, but only when the aim button is being held down. The problem I have is when mapping the controls to the triggers. See the Left and Right triggers are recognized in unity as one input, specifically an axis, not a button. If you press down the left trigger, unity recognizes the axis to be > 0. If you press down the right trigger then unity recognizes the axis to be < 0. Here's my problem,

    the axis can't be > 0 AND < 0 at the same time .

    But i need to hold down both triggers to aim + shoot (Resident Evil Style). Is there a way to separate the two triggers? Or is there another solution?


  2. Location
    Hampshire, UK
    Posts
    944
    No, there's no way to separate the triggers. I reported it as a bug some months back, but it's still open. I included a sample project with the report, but if you feel you have anything to add, I guess you could submit your own bug report.


  3. Location
    UK
    Posts
    158
    It's not a bug: If you're using an original xbox pad on the pc (not a 360 one) then go into the windows control panel and using the xbox pad config manager assign the triggers to be both on different axis: You'll be able to happily use them both at the same time in unity then...

    Without setting them like this you'll struggle to find any software that will let you use them independantly.


  4. Location
    Hampshire, UK
    Posts
    944
    Quote Originally Posted by Amazingint
    It's not a bug:
    That's funny. When I contacted Unity Support, they said it was, and asked me to submit a bug report.

    If you're using an original xbox pad on the pc (not a 360 one)
    I'm talking about the 360 one. I assumed the original poster was too, since there was no officially PC compatible version of the original controller, and he does says XBox/PC.

    then go into the windows control panel and using the xbox pad config manager assign the triggers to be both on different axis: You'll be able to happily use them both at the same time in unity then...
    Well it's good to know that this is possible on the original controller, but there is no such option on the 360 controller, as it's intended to be read using XInput, not DirectInput. I don't know for sure but I suspect Unity is using DirectInput.


  5. Location
    UK
    Posts
    158
    Ah my bad...I use an original xbox pad (all 16 buttons are potentiometers!) with xbmc it's shown as a windows gamepad.

    Damn new fangled 360 pads


  6. Location
    Phoenix, AZ
    Posts
    1,251
    This is indeed a DirectInput versus XInput problem. You can't access the triggers independently through DirectInput (which appears to be deliberate on Microsoft's part, to push people into XInput).

    There is already a plugin for Unity that provides support: http://speps.fr/xinputdotnet . However, it isn't 100% "pure" CIL, as it claims, so you can't use it in the web player (and will likely need Unity Pro). Their DLLs aren't safe for distribution, either; you should recompile statically if you use them.
    Matthew Wegner
    Current Project: Aztez
    Elsewhere:
    Founder, Flashbang Studios
    Partner, Indie Fund
    Editor, Fun-Motion
    Co-Chair, IGF


  7. Location
    Ontario
    Posts
    19

    xbox 360 controller

    I meant the 360 controller, not the original xbox.


  8. Location
    France
    Posts
    22
    Quote Originally Posted by Matthew
    There is already a plugin for Unity that provides support: http://speps.fr/xinputdotnet . However, it isn't 100% "pure" CIL, as it claims, so you can't use it in the web player (and will likely need Unity Pro). Their DLLs aren't safe for distribution, either; you should recompile statically if you use them.
    Well, it's pure in the sense that it works on Unity/Mono and of course it's not 100% "pure" CIL because it uses DirectX. It's just an interface using P/Invoke and a "homemade" DLL.

    What do you mean by "not safe for distribution"?


  9. Location
    Zürich, Switzerland
    Posts
    26,572
    Quote Originally Posted by Matthew
    This is indeed a DirectInput versus XInput problem. You can't access the triggers independently through DirectInput (which appears to be deliberate on Microsoft's part, to push people into XInput).
    Actually thats incorrect.
    The Problem is a XBox360 DInput driver problem.
    Microsoft "fucked the triggers up" by intend.

    There are kind of three solutions:

    1. See above, the .net xinput thingy

    2. There are inofficial community supported drivers for the joypad that solves the problem.

    3. Work with the triggers as they are meant to by their design.
    The triggers are seen as a single joystick axis with the R Trigger going from 0 to 1 and the L trigger going from 0 to -1 on the same axis. If both are pressed at the same time they negate the effect of each other to offer a "smooth accelration + break" effect (as racing games and games with similar acc / break schemes are the primary reason for the triggers)


  10. Location
    Phoenix, AZ
    Posts
    1,251
    Quote Originally Posted by speps
    What do you mean by "not safe for distribution"?
    The DLLs are dynamically linked and have DLL dependencies. It won't work on a fresh Windows 7 install, for install. In Visual Studio you can update the options to statically link--off the top of my head I think it's /MT instead of /MD on the code generation properties...
    Matthew Wegner
    Current Project: Aztez
    Elsewhere:
    Founder, Flashbang Studios
    Partner, Indie Fund
    Editor, Fun-Motion
    Co-Chair, IGF


  11. Location
    France
    Posts
    22
    Quote Originally Posted by Matthew
    Quote Originally Posted by speps
    What do you mean by "not safe for distribution"?
    The DLLs are dynamically linked and have DLL dependencies. It won't work on a fresh Windows 7 install, for install. In Visual Studio you can update the options to statically link--off the top of my head I think it's /MT instead of /MD on the code generation properties...
    Thanks for the tip, I often forget to make the change in my projects. It's fixed now and available on my website (see signature).
    http://speps.fr - video games programmer
    http://puddle-game.com - Puddle (IGF 2010 Student Showcase Winner)
    http://paperplane-game.com - PaperPlane (IGF 2011 Student Showcase Winner, Unity 2.6)
    http://speps.fr/xinputdotnet - XInput.NET, Xbox 360 Controller support for Unity3D

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •