Search Unity

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

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

  1. Staples

    Staples

    Joined:
    Jan 14, 2009
    Posts:
    224
    Hey, nice script.

    I was wondering though - it doesn't seem to allow multiple keybinds (such as Ctrl + 1 etc). Would it be possible to do this?
     
  2. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Posts:
    198
    I haven't build that in but my gues it can't be too hard to do that. You will have to alter the script to do this though.
    I'm working with a small team on 2 games so i don't really have the time to look into that,i'm sorry.

    i try something out of my head...don't copy over this code without checking for errors ;)

    Code (csharp):
    1.  
    2. if (inputManager.isInputDown[25]  Input.GetKey("left ctrl"))
    3.     {
    4.        // do code
    5.     }
    6.  
    you will have to alter the OnGUI() code to show these new controlls though.

    I hope this helps
     
  3. sh0v0r

    sh0v0r

    Joined:
    Nov 29, 2010
    Posts:
    325
    I've integrated Roidz system into my game Lunar Flight www.shovsoft.com

    It's a pretty solid framework to build from and Roidz has done a great job, but be aware depending on the complexity of your game there will be some extra code required to make it work.

    During the integration I discovered a few things relating to analog joysticks that may help others.

    For Keyboard input I added Clamping function called from with the custom_input class each update:
    It's better to do this here rather than in your input controller code so you can treat it like a black box and just ask for the current value.

    Code (csharp):
    1.  // FORWARD
    2.         if (isInput[0]) // ON
    3.         {
    4.             analogFeel_forward += analogFeel_sensitivity * Time.deltaTime;
    5.             if (analogFeel_forward >= 1f) analogFeel_forward = 1;
    6.         }
    7.         if (!isInput[0]  analogFeel_forward > 0) // OFF          
    8.         {
    9.             analogFeel_forward -= analogFeel_gravity * Time.deltaTime;
    10.             if (analogFeel_forward <= 0) { analogFeel_forward = 0; }
    11.         }
    Lunar Flight is designed to use analog inputs and Roidz current system treats joysticks as digital.
    You will need to reduce the detection ranges in the inputSetBools() function to ensure you get the full range of input and not just the end at full deflection.

    The method for making any 'Axis' a default setting as menioned here in the forum will work but it will also overwrite the players setting the next time they load the game. Having the checDoubleAxis() function after saving will cause the first index to get set to None. Not sure why but I decided to leave it out since I am only using it to reset my controls to defaults when the button is pressed. I created an aditional function with all the Axis inputs I need to reset in there so it can be called from any function either load config or reset 2 defaults. The system really needs a way of binding the joystick Axis in the inspecter.

    All of my input controller code is dependant on the input values from -1 to 1. Binding each axis tured out to be uneccesary as Input.GetAxis will return the value you need so you only need to check JoystickUp to also get the opposite input value. It's good that both directions are able to be set for keyboard inputs though.

    Code (csharp):
    1. // Left X360 Joystick - Translate
    2.         // Left Stick Vertical
    3.         // Forward
    4.         if (inputManager.joystickActive[0]) current_LJ_VerticalInput = -Input.GetAxisRaw(inputManager.joystickString[0]);
    5.         if (inputManager.joystickActive2[0]) current_LJ_VerticalInput = -Input.GetAxisRaw(inputManager.joystickString2[0]);        
    6.  
    7.         /* Backward This is redundant since Input.GetAxis will return both directions
    8.         if (current_LJ_VerticalInput == 0)
    9.         {            
    10.             if (inputManager.joystickActive[1]) current_LJ_VerticalInput = Input.GetAxis(inputManager.joystickString[1]);
    11.             if (inputManager.joystickActive2[1]) current_LJ_VerticalInput = Input.GetAxis(inputManager.joystickString2[1]);
    12.         }*/
    13.  
    14.         if (current_LJ_VerticalInput == 0) // Test keyboard Input
    15.         {            
    16.             if (inputManager.isInput[0]) current_LJ_VerticalInput = -inputManager.analogFeel_forward;
    17.             if (inputManager.isInput[1]) current_LJ_VerticalInput = inputManager.analogFeel_backward;
    18.         }
    19.  
    20.         // Makes sure we return to 0 when there is no joystick present
    21.         if (!inputManager.joystickActive[0]  !inputManager.joystickActive2[0])
    22.         {
    23.             if (current_LJ_VerticalInput < 0  thrustForward) current_LJ_VerticalInput = -inputManager.analogFeel_forward;
    24.             if (current_LJ_VerticalInput > 0  thrustBack) current_LJ_VerticalInput = inputManager.analogFeel_backward;
    25.         }        
    26.  
    27.         if (current_LJ_VerticalInput < 0.0)
    28.         {
    29.             //Debug.Log("LJ_Down Forward!");
    30.             rigidbody.AddRelativeForce(-(Vector3.forward * current_LJ_VerticalInput * JetFactor));
    31.             fuel -= (current_LJ_VerticalInput / 2) / jetFuelBurnRate;
    32.  
    33.             thrustForward = true;
    34.             thrustBack = false;
    35.         }
    36.         else if (current_LJ_VerticalInput > 0.0)
    37.         {
    38.             //Debug.Log("LJ_Down Back!");
    39.             rigidbody.AddRelativeForce((Vector3.back * current_LJ_VerticalInput * JetFactor));
    40.             fuel -= (-current_LJ_VerticalInput / 2) / jetFuelBurnRate;
    41.             thrustBack = true;
    42.             thrustForward = false;
    43.         }
    44.         else
    45.         {
    46.             thrustBack = false;
    47.             thrustForward = false;
    48.         }
    Here's a screenshot:

     
  4. Phyrefly

    Phyrefly

    Joined:
    Apr 9, 2011
    Posts:
    15
    Has anyone looked at fixing the bug around changing the size of the arrays? This happens every time for me, so I have to keep setting my input keys.

    I can have a look at fixing it, but if someone else already has, why duplicate effort! :)

    Either way, thanks a ton Roidz for the script, it is super-fast.
     
  5. Deleted User

    Deleted User

    Guest

    Lovely script thx m8!! :)
     
  6. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,467
    hey man, sorry to bump this thread, but I am using Antares universe and I am wondering if i could integrate this into Antares...? I already have it set up to read my inputs...
     
  7. Roidz

    Roidz

    Joined:
    Apr 17, 2010
    Posts:
    2
    Yes ofcourse, sorry for the late reply...
     
  8. Wasabi667

    Wasabi667

    Joined:
    Jan 6, 2012
    Posts:
    1
    Hi do you make an update from your Script. Because it seems to be unusable with new Unity versions. It seems like, that the default input axis are not the same anymore.
     
  9. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Posts:
    198
    hey, Unity changed the location of the inputmanager.asset file i think,thats prolly the reason.
    try moving the file into \ProjectSettings\

    I'm pretty sure this should work...


    On the other hand, you can wait a little while for version 2 of my inputmanager.

    I finally decided to get this project to a new level.

    It's more flexible,more powerfull, and no setting up anymore (except the nee still for inputmanager.asset)...


    The script will function in the same way as iTween does. So you just drop it in the plugins folder and it will work.

    It is almost ready but i need a few beta testers, preferable people who allready know what they are doing :)

    Send me an email if you want to betatest the script. The new version will prolly cost 10 dollars or something,but as i mentioned in the past, everyone who donated before this date will get inputmanager 2.0 for free (just drop me a email).

    I hope some people see this because i don't want to start a new tread for inputmanager2.0 untill i'm convinced its ready to go :)

    If there are some people that want to make some small examples which could be included in the official release i would appriciate it even more.
    mail me if you are interested : Ward.Dewaele@pandora.be
     
  10. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,467
    I just wish there was a wizard for all of this... just plug in the controller and the wizard will allow you to choose buttons etc
     
  11. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Posts:
    198
    I'm happy to anounce the birth of
    cInput2.0

    Check out the forumpost HERE

    This is the updated version of 1.4 - Check out the website to see the improvements :)

    This week only for 10 dollars !

    PS : people who donated prior to april 1 will get cInput2.0 for free ! Email me if you haven't got it yet !
     
  12. gameboyyo

    gameboyyo

    Joined:
    Jul 16, 2011
    Posts:
    20
    Hello, i wanted to know if it's possible to 'get the axis button/ key' with this the free or paid version of your app.
    Basically, if it allows you to tell the player
    Press 'u' to interact <= key associated with 'Interact' axis in input manager
    instead of
    Press 'Interact' to interact <= name of the axis.

    Thanks.
     
  13. Roidz99

    Roidz99

    Joined:
    Jul 8, 2010
    Posts:
    198
    In cInput2 you get following functions

    cInput.GetKey("Up");
    or
    cInput.GetButton("Up")

    Ofcourse also GetKeyDown and GetKeyUp (and GetButtonDown and GetButtonUp) work just as the Input class counterpart.

    as for axis ...
    cInput.GetAxis("Horizontal");
    works just like it works in the Input class

    To get more info about this check out the cInput2 website, you can download the reference manual or watch some videos...

    cInput 2 website
     
  14. UnityExample

    UnityExample

    Joined:
    Aug 14, 2012
    Posts:
    2
    is it possible to support full 900° USB Steering wheel with this inputmanager? and can i delete the deadzone?
     
  15. Angry-Armadillo

    Angry-Armadillo

    Joined:
    May 28, 2013
    Posts:
    4
    Has anyone been able to get this working with unity 4.1? I followed through all the instructions and all I get is non-responsive controls, sometimes they work, most of the time not. Also Unity throws a bunch of input not set up -errors.
     
  16. DRProductions

    DRProductions

    Joined:
    Jan 21, 2013
    Posts:
    15
    Thanks man, if this has controller support you just saved my project! does it?