1. We've introduced thread tags, search within a thread and similar thread search. Read more here.
    Dismiss Notice
  2. We've released our first Timeline Experimental Preview, our new tool for creating cutscenes and more! To check it out click here.
    Dismiss Notice
  3. All Unity Pro perpetual license customers: your special offer to subscribe is ready! Click here.
    Dismiss Notice
  4. Unity 5.5 is now released.
    Dismiss Notice
  5. Check out all the fixes for 5.5 in patch releases 1 & 2.
    Dismiss Notice
  6. Unity 5.6 beta is now available for download.
    Dismiss Notice
  7. Get prepared for the Tizen Mobile App Incentive Program! Read more about the upcoming program here.
    Dismiss Notice
  8. Enter the Microsoft Developer Challenge for a chance to win prizes. Read more about it here.
    Dismiss Notice

Custom Inputmanager v1.4 - VERY easy to use now !

Discussion in 'Made With Unity' started by Roidz99, Jul 8, 2010.

  1. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Messages:
    186
    After using Unity for a while now, i fell in love with it.
    Ofcourse there are a few (minor) flaws in unity and one of them is the inputmanager. On itself it works how it should be but the lack of calling it back from script to let players config inputs on the fly is a big downer for many...

    therefore i present:

    Unity Custom Inputmanager v1.4

    - Very simple to implent in your project (new)
    - Allows your players to customise inputs when u want
    - Handles all keys,mouse and joystick input, including axes.
    - Saves the configuration to 'PlayerPrefs'.
    - This also works for 'webbuilds'

    I release this for free because i got a lot back from the community allready, ofcourse i don't mind a donation :D

    go to this website to download it for free.
    http://roidz.weebly.com/

    Any questions about this can be asked here or to my email:
    ward.dewaele@pandora.be

    Have fun :wink:

    EDIT: this is updated to v1.4

    Changes from 1.3:
    - 100X easier to implent in your project now
    Download and check out the included PDF for a simple walkthru


    Changes from 1.2d:
    - Added the option to allow / disallow duplicate inputkeys,set in the inspector.

    Changes from 1.2c:
    - Fixed a bug that could cause joystick axes to behave weird
    - Nicer look of the playtable -thanks to Starcruiser (Ian Kirkland)
    - Menu buttons are now autocentered -thanks to Starcruiser (Ian Kirkland)

    Changes from 1.2b:
    - Fixed a bug that caused the right joystick input to be way too sensitive. (thanks to Starcruiser bigkahuna)

    Changes from 1.2:
    - Fixed a bug that stopped u from increasing the amount of inputs
    - Improved the looks a bit

    Changes from 1.1:
    - added full support for xbox360 controller (also the triggers) - this is tested on the mac, but untested on windows yet. Try it on windows please and let me know if it works or not.

    Changes from 1.0:
    - Added alternative inputbutton
    - Changed some variables in the inspector to make things more clear
    - Removed variables from inspector that shouldnt be visible
    - Added a helpfile :)
    - Download file as a zipfile now

    [​IMG]

    Web Example of V1.3 how it could look ingame
    http://users.telenet.be/ward.dewaele/input/CustomInputManagerv1-3.html
     
  2. gamesurgeon

    gamesurgeon

    Joined:
    Oct 11, 2009
    Messages:
    427
    Thanks!
     
  3. Maurice-Hoffman

    Maurice-Hoffman

    Joined:
    Jan 22, 2009
    Messages:
    170
    Thanx, I am gonna test it.
     
  4. theinfomercial

    theinfomercial

    Joined:
    Sep 9, 2008
    Messages:
    1,000
    Thank you for this! :)

    Yeah, it's a bummer that you can't access the Input manager through script, as it's so important for in game menus.
     
  5. Maurice-Hoffman

    Maurice-Hoffman

    Joined:
    Jan 22, 2009
    Messages:
    170
    Hello Roidz,

    I have tested it and i have use for it.

    The only fault it has when i click on one of the inputs, it expects that mouse 0 is the chosen key.

    Maybe you can make next to the key input a change button, so when you click this with the mouse, you can input the chosen key, joybutton etc.

    Keep up the good work.
     
  6. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Messages:
    186
    Do you mean that to start choosing a new key, u first have to click with the left mouse on the button ? I think thats normal behaviour.

    If you want to select a new input for a controll, just click once with the mouseon on a button, the button will be greyed out, this means that that button is gona receive the next input you will do, that can be a mouseclick, keyboard input, joystick button or axis, or even mouse axis (if you turn it on in the inspector).

    Or do u mean you would like an option to turn off mouse input at all ? so players can not select mousebuttons as input ? - i can do this ofcourse, let me know if this is a requested feature.

    I hope this helps,let me know if it doesnt.
     
  7. Creative

    Creative

    Joined:
    May 8, 2010
    Messages:
    184
    Good job Roidz! Well done.
    Definitely will help me in the feature and save me some hours.
     
  8. Maurice-Hoffman

    Maurice-Hoffman

    Joined:
    Jan 22, 2009
    Messages:
    170
    Thanx Roidz,

    You are right, i click to fast.

    I meant a separate button next to the other one, to click to make the selection, and that than you choose the mouseclick, keyboard input, joystick button or axis, or even mouse axis

    But i try it the way you explained.
     
  9. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Messages:
    186
    ah i see... well isnt it better that you do that yourself, i mean, the functionality is there, how it looks i leave to the programmer itself. Personally i wouldnt like seperate buttons next to eich other to set input on/off. But if there are more people requestig this i might do it anyway.
     
  10. mikesgames

    mikesgames

    Joined:
    Apr 16, 2010
    Messages:
    1,072
    Thanks, now downloading and testing!
     
  11. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Messages:
    186
    I updated the inputmanager to 1.1

    this is updated to v1.1

    Changes from 1.0:
    - Added alternative inputbutton
    - Changed some variables in the inspector to make things more clear
    - Removed variables from inspector that shouldnt be visible
    - Download file comes as a ZIP file now on request
    - Added a helpfile

    At first i forgot to mention this also works in webbuilds ofcourse !
     
  12. theinfomercial

    theinfomercial

    Joined:
    Sep 9, 2008
    Messages:
    1,000
    This is great, but I tried to use the triggers on an xbox 360 controller, and the manager doesn't seem to recognize them. Is there any way to get the manager to detect the xbox 360 triggers?
     
  13. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Messages:
    186
    to be honnest ,i wouldnt know, i dont have a xbox 360 joypad so i can't test it myself, can u use the controller with the default inputmanager ?
     
  14. theinfomercial

    theinfomercial

    Joined:
    Sep 9, 2008
    Messages:
    1,000
    Yes. It works with your input manager. The only thing it doesn't recognize is the triggers. And I want it to be modifiable, so I can't use the default input manager.
     
  15. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Messages:
    186
    do u think u can come on the irc channel ? message me there.
    I need to get some info to be able to do it. think i can add it with the correct info. I'm online now as |Roidz|
     
  16. theinfomercial

    theinfomercial

    Joined:
    Sep 9, 2008
    Messages:
    1,000
  17. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Messages:
    186
    This is updated to 1.2

    New in this version...

    - Full xbox controller support (including left and right trigger)

    tested on the mac (thanks to theinfomercial) - but untested on windows yet - soon we will test this on windows to make sure it works.

    Link is in my signature or in the first post.
     
  18. theinfomercial

    theinfomercial

    Joined:
    Sep 9, 2008
    Messages:
    1,000
    I have tested it on Windows and it works to the best of my testing ability. The gamepad mapping is of course different than it is on the Mac, and the triggers get mapped to axis 3 for negative and positive. This means that pulling both triggers will nullify their inputs. This is expected, as windows by default uses direct input instead of xinput. I don't know if there's a way to activate xinput, as I'm not sure if I even have it installed (couldn't find it). :)

    Regardless, the xbox controller is handled in the custom input manager very well, fully mappable, and should work for everyone. :)
     
  19. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Messages:
    186
    Thanks for testing ,and great it works !

    but i found a bug in my code, it wouldnt allow you to increase the amount of inputs without going in the registry.

    This should be fixed in build 1.2b - like always: the link is in my signature or at the main page.


    Changes from 1.2:

    - Fixed a bug that stopped u from increasing the amount of inputs
    - Improved the looks a bit
     
  20. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Messages:
    186
  21. Joe ByDesign

    Joe ByDesign

    Joined:
    Oct 13, 2005
    Messages:
    841
    Great work Roidz!
     
  22. GeneralGrant

    GeneralGrant

    Joined:
    Jun 10, 2010
    Messages:
    977
    does anyone even own an xbox debugger?
     
  23. Maurice-Hoffman

    Maurice-Hoffman

    Joined:
    Jan 22, 2009
    Messages:
    170
    Roidz,

    Many thanx you adressed all my niggles.
     
  24. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Messages:
    5,425
    Great idea, but I've run into a few issues. It seems that the left joystick in put is a bit flakey. Sometimes when I try to set the joystick it works, but other times it doesn't it just defaults to "Right Joystick". I have to re-start the game to fix it. Seems to work better in your webplayer than it does in the Unity editor (I'm running 2.6.1 on a Mac). The other issue happens if you set Jump to a joystick axis, try it and you'll see what I mean.
     
  25. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Messages:
    186
    I think this is a problem with your joystick axis, that it constantly leans heavy to the right all the time. I have a joystick exactly like that. It doesn't stay 'neutral' when at rest. I think you should 're-callibrate' your joystick. In windows you can do that in the windows configuartion, i don't know how to do it on a Mac.

    try making sure that the horizontal axis of your joystick is at the middle and doesn't lean slightly to the right.

    I can propably fix this with making a bigger 'deadpoint' - but this is so joystick independant that this is more a joystick problem then a inputmanager problem.

    I tried it and i saw it ! I'm gona try to fix this bug soon! thanks for pointing me to that !
     
  26. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Messages:
    5,425
    Actually the problem seems to have to do with the sensitivity setting in your script, but it only happens with the left joystick and I'm using a Logitech Rumblepad 2. If I test the stick with another app, it shows the inputs as "0" when in the centered position.
     
  27. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Messages:
    186
    i will go over the sensitivity settings but i think they are all the same for all axis. Won't be for today, but for sure early this week,i keep you posted.
     
  28. Starcruiser

    Starcruiser

    Joined:
    Oct 30, 2007
    Messages:
    12
    After 4 hours of head-scratching-script-reading-mayhem, I have found the "joystick right" problem. In the Input Manager (Edit>Project Settings>Input) the 'joystick right' (fourth entry) has a Gravity and Sensitivity of 1000! The first three entries' (up,left,down) Gravity and Sensitivity are at 3. Change 1000 to 3 and it all works great, glad it was that simple.

    On a better note, I am using a Philips Recoil pad on a new iMac and all works well :D ... except the D-pad. Up, right, and down, all work, left is not recognized. I even 'reactivated' the code that was commented out for the Xbox360 pad, and no difference.

    I added some walls, and also tweaked the GUI elements' (X and Y floats/vars) to keep the buttons centered on screen, which was tricky as I am not comfortable with C#. I'm curious if this script would have been possible in JS...

    @ Roidz99 - Let me know if I may upload what I have for your review and for the people. Nice work sir!
     
  29. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Messages:
    186
    yes please, i will even upload it to the website if i think it will help the community !

    About the JS version of it, i was thinking about converting it. I'm pretty sure it's 100% convertable to JS

    And about the 'bug' - good catch , i didn't had time to check the settings yet ,but that would be the first thing i would look at,i'll fix that first so people dont get the 'wrong' version of it.

    EDIT: uploaded the newest version to begin post (or go to the link in my signature)
    Changes from 1.2b:
    - Fixed a bug that caused the right joystick input to be way too sensitive. (thanks to Starcruiser bigkahuna)
     
  30. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Messages:
    186
    Those issues are also solved now,updated the main post the website.


    Changes from 1.2c:
    - Fixed a bug that could cause joystick axes to behave weird
    - Nicer look of the playtable -thanks to Starcruiser (Ian Kirkland)
    - Menu buttons are now autocentered -thanks to Starcruiser (Ian Kirkland)
     
  31. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Messages:
    5,425
    Looks good, no issues here. Nice job!
     
  32. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Messages:
    186
    building a check for duplicates - will be able to turn on/off in the inspector... will be ready this evening
     
  33. holger53

    holger53

    Joined:
    Mar 15, 2010
    Messages:
    30
    Very nice!

    It would save me hours - no days!

    Now all I need is some kind of force feedback

    for the rumblepad, xbox-controller or PS3--

    controller! :wink:
     
  34. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Messages:
    186
    I'm afraid that's not possible without some external dll. But to be honnest, i don't have a clue. I don't think Unity supports it as default, correct me if i'm wrong.

    I hope so ;) Make sure to get the latest version i'm uploading now ! v1.3 - now you can choose if duplicate keys are allowed or not (set in the inspector)

    Link is like always in the main post or my signature.
    You can try the latest build in a webbuild by clicking here :http://users.telenet.be/ward.dewaele/input/CustomInputManagerv1-3.html

    PS: I have some good ideas how to improve this inputmanager and make it even easier to use but i can't help myself pointing out that even its completely free to use for comercial/non comercial games ,a donation is welcome.

    Currently i have received no donations at all,which makes me think this inputmanager is completely useless for everyone or ... (fill in yourself)
     
  35. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Messages:
    186
    Had some updates almost ready but will have to wait because i have my hands full working on our game.

    Questions or requests can still be asked, this project isn't dead.
     
  36. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Messages:
    186
    New version out !

    1.4 allows you to implent the custom inputmanager a lot easier.
    Read the included pdf file and follow the easy step by step walktru to implent this in your game in minutes.

    Changes from 1.3:
    - 100X easier to implent in your project now
    Download and check out the included PDF for a simple walkthru

    Like always... link is in my comment or on the first post.
     
  37. psychicparrot

    psychicparrot

    Joined:
    Dec 10, 2007
    Messages:
    866
    Thanks for sharing this - it looks like it could be REALLY useful :)
     
  38. zelk

    zelk

    Joined:
    Mar 13, 2009
    Messages:
    246
    Wow, just what I was looking for. I will try this with steering wheels and report back if it works or not. If I use the script in my projects, you will get a donation for your effort.
     
  39. zelk

    zelk

    Joined:
    Mar 13, 2009
    Messages:
    246
    I tried your web demo with a G25 steering wheel. A few issues:

    1. A G25 racing wheel default setup is such as the accalerator pedal is at -1 when up and +1 when full down and 0 in the middle. Your script does not handle this. Maybe one could check for movement of the axes instead of reading static inputs... or when reading analog inputs, ask the user to move the axis to it's full extents.

    2. It does not seem possible to read analog input from the controllers, only on/off states, which means a steering wheel or analogue sticks of joysticks does not behave as expected.

    Do you have any plans of implementing this?

    Do you think that the way your script is written, it is possible to add support for that (if I sit down and read it through)?
     
  40. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Messages:
    186
    if you want to use the real analog input from a joystick (like a steering wheel) then you need to use something like :

    steer = Input.GetAxis(inputManager.joystickString[n]) - where n is the inputkey - this will only work if a joystick is set as input, so you need to check if inputManager.joystickActive[n]==true first so your code would be,if your steering wheel axis is on input 0

    Hope this helps, if not we fix this in irc or something, so we can resolve it in realtime.
     
  41. zelk

    zelk

    Joined:
    Mar 13, 2009
    Messages:
    246
    Hi, thanks for answering. I have decided to create my own solution. I have some different needs and had already started when I found your solution so I will continue with mine. Anyway, great work!
     
  42. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Messages:
    186
    okay, consider sharing yr sollution to the comunity ;)
     
  43. Joe ByDesign

    Joe ByDesign

    Joined:
    Oct 13, 2005
    Messages:
    841
  44. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Messages:
    186
    it's allready in the wiki
     
  45. unitrix

    unitrix

    Joined:
    Mar 19, 2010
    Messages:
    279
    Hey Roidz thx for this, its awesome! I had made an input manager a few months ago that took me a few days, the code was extremely longer and no where near as efficient as yours, I actually looked at it the other day and could barely remember how to get mine to work. Anyway yours is awesome and thanks!
     
  46. coin-god

    coin-god

    Joined:
    Jan 21, 2010
    Messages:
    325
    How do I write this in a JS script?

    Code (csharp):
    1. public custom_inputs inputManager
    And should I put it in the FPSWalker script? From the FPController.
     
  47. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Messages:
    186
    Code (csharp):
    1. var inputManager : custom_inputs ;
    make sure the custom_inputs script is in the 'Standard Assets' folder,or else it won't work.



    Where ever you normally put yr controll code would work.
     
  48. coin-god

    coin-god

    Joined:
    Jan 21, 2010
    Messages:
    325
    Oh, that was the problem.
     
  49. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Messages:
    186
    glad it helped... i will update the pdf help file soon with the javascript code/way to do it.
     
  50. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Messages:
    186
    I had someone ask over email how to set mouse axis as default inputs. This is not possible in the inspector but you can still do it with script.


    - Open the custom_inputs.cs in your favorite code editor.
    - Find the loadConfig() function and add this to the bottom (under the for loop) :

    Code (csharp):
    1.  
    2.         // delete the key
    3.         inputKey[0] = KeyCode.None;
    4.         // state we are using the joystick axis on this
    5.         joystickActive[0] = true;
    6.         joystickString[0] = "MouseUp";
    7.         // Update the buttons inputstring to the new key
    8.         inputString[0] = "Mouse Up";
    9.         // save our configuration
    10.         saveInputs();
    11.         // check for doubles
    12.         checDoubleAxis(joystickString[0], 0, 1);
    13.  
    That should do the trick. Like this you will have mouse up be the default input for the up movement.

    Ofcourse you can change 'MouseUp' and 'Mouse Up' for other mouse axis inputs (also joystick axis inputs)
     
    Last edited: Oct 29, 2010