Search Unity

Rewired - Advanced Input for Unity

Discussion in 'Assets and Asset Store' started by guavaman, Sep 25, 2014.

  1. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    I do not know. Check the source code of the PlayMaker Action. If it uses "Input.GetAxis" and not "UnityEngine.Input.GetAxis" then it will work. Rewired comes with PlayMaker Actions you can use anyway.
     
  2. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    It looks like the Unity Asset Store has a lot of items in their queue since Rewired 1.0.0.87 is not out yet. I am looking forward to that new HOTAS and other templates! These templates will save me a large amount of time in flight sim testings.
     
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
  4. OneThree

    OneThree

    Joined:
    Oct 28, 2011
    Posts:
    181
  5. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    guavaman likes this.
  6. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    No it doesn't. Sorry.
     
  7. acgleader

    acgleader

    Joined:
    Apr 17, 2013
    Posts:
    40
     
  8. acgleader

    acgleader

    Joined:
    Apr 17, 2013
    Posts:
    40
    Does it support android for input frame-rate independent input?
     
  9. beNice

    beNice

    Joined:
    Sep 12, 2014
    Posts:
    28
    Hey, @guavaman.

    Would it be possible to have more PlayMaker Actions for Rewired created, especially for user-mapping and layouts? We have tried the excellent Control Mapper prefab but need something a bit more customizable and run-time for our project; nice job on that prefab though.

    Also, the Rewired PlayMaker Actions are all together in scripts so you cannot easily edit them like other Actions. Is there a reason for this, as in less code or making it easier to update?

    Lastly, the Rewired Player Get Button Down, PlayMaker Action seems to behave outside of the normal PlayMaker Get Button Down Action. With the Rewired version, if you have to move between two states it gets caught in an infinite loop, whereas with the default Action, it waits for the button to get pressed again and again.

    Thanks so much for your great work.
     
  10. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    No it does not.
     
  11. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    Unfortunately, that's not feasible. The API required to build a custom controller remapping system with conflict checking is very, very large and involves dealing with a lot of large structs and other data types. It's just infeasible to do that kind of complex coding task through PlayMaker.

    Simply for convenience as I was making it. It has no effect on updating or anything else. Editing the Actions is not recommended as your edits will be overwritten the next time you update Rewired. A better solution is to copy the Action and make a new class with a different name.

    I will check the Action and see if there is anything that needs to be changed.
     
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    After investigation, this only happens when an "Is True Event" is set causing it to fire an event when evaluating to true.

    For some unknown reason, PlayMaker calls "OnEnter" again each time an event is fired. These Actions are patterned after PlayMaker Actions that 1) Fire events on some criteria 2) Have an "Every Frame" option. The Action evaluates each time OnEnter or OnUpdate is run by PlayMaker. Because the event is evaluated and triggered from OnEnter, after the event fires, PlayMaker then runs OnEnter again causing another event to be fired, then OnEnter is called again for that event, and on and on infinitely. I do not know why PlayMaker would run OnEnter again when an event is fired -- it does not seem to make any logical sense from my perspective. The end result is one can never fire an event from within OnEnter or it will cause an infinite loop.

    The reason why the default GetButtonDown does not do this is that it does not have the option of Every Frame and instead always runs every frame and it does not have an OnEnter method override, instead doing all its code in OnUpdate.
     
  13. beNice

    beNice

    Joined:
    Sep 12, 2014
    Posts:
    28
    Okay. Thanks for the quick reply and looking into Get Button Down.

    We will try harder with Control Mapper to make it work for us.

    EDIT: Oh, maybe a separate Action could be made that has no "Is True Event"?
     
  14. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    You can already just leave off the event. You don't need a new Action to do this. You can store your Boolean and not fire an event directly from this Action and it won't go into an infinite loop.

    According to PlayMaker's author, the solution for this issue is to use the Next Frame Event:
    http://hutonggames.com/playmakerforum/index.php?topic=6511.0

    I will be reworking these Actions to try to make them work as one would expect they would and will probably be changing each Action as necessary to inherit from a different class with differing options. This may mean GetButton will no longer allow events (as PlayMaker's GetButton doesn't have them) and GetButtonDown will no longer have "Every Frame" setting or the "Is False Event" or "Value Changed Event". A number of Actions will need to be changed as many inherit from the same base classes.
     
    Last edited: May 26, 2016
  15. beNice

    beNice

    Joined:
    Sep 12, 2014
    Posts:
    28
    Sounds good, man. I'll work around in the meantime.

    Thanks for your continued vigilance.
     
  16. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    The attached replacement PlayerActions.cs file should fix the issue and hopefully not cause any unintended side effects with other Actions.
     

    Attached Files:

  17. VoidFish

    VoidFish

    Joined:
    Nov 27, 2012
    Posts:
    31
    Hey, I'm sorry if this has been asked / mentioned somewhere, but I can't find information about it.

    Is there anything special that needs to be done to support the steam controller? I'm having trouble getting it to work. Some actions work, but some don't, and I can't reassign buttons.
     
  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    There is quite a bit of documentation on the Steam Controller:

    Supported Controllers - Steam Controller
    Troubleshooting - Steam Controller
    Troubleshooting - Steam Controller is not detected (Windows)
    Troubleshooting - Steam Streaming controller support on Linux/SteamOS
    Troubleshooting - Steam Controller doesn't work with other controllers at the same time in Windows
     
  19. Doghelmer

    Doghelmer

    Joined:
    Aug 30, 2014
    Posts:
    120
    How can I set a gamepad's right-stick dead zone from within the code? I wasn't able to find a reference to this in the documentation. Normally it can be set on the 'calibrate controller' window in the Control Mapper, but I'd like it to have a specific default value when the user starts playing.
     
  20. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    How To's - Calibrating controller axes

    Whether or not a right stick exists will depend entirely on the current controller being used. If your plan is to force a specific calibration in code on all players for all controllers, you might be better off doing manual calibration on the results of Actions assigned to the right stick instead. As the FAQ notes, joystick calibration is very specific to each individual device and should generally be left up to the user to set manually.

    The Joystick object has no relation to the mapping template in the editor, so you will not have access to Dual Analog Gamepad Template elements on the Joystick to say "get right stick X" from code. In Rewired, a Joystick only contains a list of buttons and axes. The Template only exists as a way to create a Joystick Map at runtime. The map converted to a native map for that specific device and the relationship to the template no longer exists. (There is a hacky way to associate a particular Joystick element to the element on the Dual Analog Gamepad Template which I added for someone who needed this functionality, but I do not recommend using this.)
     
    Last edited: May 28, 2016
  21. beNice

    beNice

    Joined:
    Sep 12, 2014
    Posts:
    28
    GetButtonDown is now working for us. Thank you so much.

    I'd like to just note that the "Is False Event" appears to trigger no matter what, but I'm not sure if it's even usable in that type of Action. Anyway, it seems to be working as intended.

    One last request before we can fully implement the excellent Rewired: Could you point us in the right direction to convert the PlayMaker Action of MouseLook to Rewired? Is it just converting a few commands and namespace?

    Thanks again. You're awesome!

    Code (CSharp):
    1. // (c) Copyright HutongGames, LLC 2010-2013. All rights reserved.
    2.  
    3. using UnityEngine;
    4.  
    5. namespace HutongGames.PlayMaker.Actions
    6. {
    7.     /// <summary>
    8.     /// Action version of Unity's builtin MouseLook behaviour.
    9.     /// TODO: Expose invert Y option.
    10.     /// </summary>
    11.     [ActionCategory(ActionCategory.Input)]
    12.     [Tooltip("Rotates a GameObject based on mouse movement. Minimum and Maximum values can be used to constrain the rotation.")]
    13.     public class MouseLook : FsmStateAction
    14.     {
    15.         public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 }
    16.  
    17.         [RequiredField]
    18.         [Tooltip("The GameObject to rotate.")]
    19.         public FsmOwnerDefault gameObject;
    20.  
    21.         [Tooltip("The axes to rotate around.")]
    22.         public RotationAxes axes = RotationAxes.MouseXAndY;
    23.  
    24.         [RequiredField]
    25.         public FsmFloat sensitivityX;
    26.  
    27.         [RequiredField]
    28.         public FsmFloat sensitivityY;
    29.  
    30.         [HasFloatSlider(-360,360)]
    31.         [Tooltip("Clamp rotation around X axis. Set to None for no clamping.")]
    32.         public FsmFloat minimumX;
    33.  
    34.         [HasFloatSlider(-360, 360)]
    35.         [Tooltip("Clamp rotation around X axis. Set to None for no clamping.")]
    36.         public FsmFloat maximumX;
    37.  
    38.         [HasFloatSlider(-360, 360)]
    39.         [Tooltip("Clamp rotation around Y axis. Set to None for no clamping.")]
    40.         public FsmFloat minimumY;
    41.  
    42.         [HasFloatSlider(-360, 360)]
    43.         [Tooltip("Clamp rotation around Y axis. Set to None for no clamping.")]
    44.         public FsmFloat maximumY;
    45.  
    46.         [Tooltip("Repeat every frame.")]
    47.         public bool everyFrame;
    48.  
    49.         float rotationX;
    50.         float rotationY;
    51.  
    52.         public override void Reset()
    53.         {
    54.             gameObject = null;
    55.             axes = RotationAxes.MouseXAndY;
    56.             sensitivityX = 15f;
    57.             sensitivityY = 15f;
    58.             minimumX = new FsmFloat {UseVariable = true};
    59.             maximumX = new FsmFloat { UseVariable = true };
    60.             minimumY = -60f;
    61.             maximumY = 60f;
    62.             everyFrame = true;
    63.         }
    64.  
    65.         public override void OnEnter()
    66.         {
    67.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
    68.             if (go == null)
    69.             {
    70.                 Finish();
    71.                 return;
    72.             }
    73.  
    74.             // Make the rigid body not change rotation
    75.             // TODO: Original Unity script had this. Expose as option?
    76.             var rigidbody = go.GetComponent<Rigidbody>();
    77.             if (rigidbody != null)
    78.             {
    79.                 rigidbody.freezeRotation = true;
    80.             }
    81.  
    82.             // initialize rotation
    83.  
    84.             rotationX = go.transform.localRotation.eulerAngles.y;
    85.             rotationY = go.transform.localRotation.eulerAngles.x;
    86.  
    87.             DoMouseLook();
    88.  
    89.             if (!everyFrame)
    90.             {
    91.                 Finish();
    92.             }
    93.         }
    94.  
    95.         public override void OnUpdate()
    96.         {
    97.             DoMouseLook();
    98.         }
    99.  
    100.         void DoMouseLook()
    101.         {
    102.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
    103.             if (go == null)
    104.             {
    105.                 return;
    106.             }
    107.  
    108.             var transform = go.transform;
    109.  
    110.             switch (axes)
    111.             {
    112.                 case RotationAxes.MouseXAndY:
    113.                    
    114.                     transform.localEulerAngles = new Vector3(GetYRotation(), GetXRotation(), 0);
    115.                     break;
    116.                
    117.                 case RotationAxes.MouseX:
    118.  
    119.                     transform.localEulerAngles = new Vector3(transform.localEulerAngles.x, GetXRotation(), 0);
    120.                     break;
    121.  
    122.                 case RotationAxes.MouseY:
    123.  
    124.                     transform.localEulerAngles = new Vector3(-GetYRotation(), transform.localEulerAngles.y, 0);
    125.                     break;
    126.             }
    127.         }
    128.  
    129.         float GetXRotation()
    130.         {
    131.             rotationX += Input.GetAxis("Mouse X") * sensitivityX.Value;
    132.             rotationX = ClampAngle(rotationX, minimumX, maximumX);
    133.             return rotationX;
    134.         }
    135.  
    136.         float GetYRotation()
    137.         {
    138.             rotationY += Input.GetAxis("Mouse Y") * sensitivityY.Value;
    139.             rotationY = ClampAngle(rotationY, minimumY, maximumY);
    140.             return rotationY;
    141.         }
    142.  
    143.         // Clamp function that respects IsNone
    144.         static float ClampAngle(float angle, FsmFloat min, FsmFloat max)
    145.         {
    146.             if (!min.IsNone && angle < min.Value)
    147.             {
    148.                 angle = min.Value;
    149.             }
    150.  
    151.             if (!max.IsNone && angle > max.Value)
    152.             {
    153.                 angle = max.Value;
    154.             }
    155.            
    156.             return angle;
    157.         }
    158.     }
    159. }
     
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    By definition, GetButtonDown will return false every frame except the one frame in which it is True, therefore the "Is False Event" will fire almost constantly.

    The documentation gives details on how to convert scripts from UnityEngine.Input to Rewired:
    http://guavaman.com/projects/rewired/docs/HowTos.html#converting-scripts

    Skip over the part entitled "The Easy Way."
     
  23. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,619
    I'm building a Windows Store / Universal 10 app, from a fresh Unity 5.3.4 project that only has a fresh import of the latest Rewired from the Asset Store in it. When making a build I get an error:
    Code (csharp):
    1. AssemblyResolutionException: Failed to resolve assembly: 'System.Runtime, Version=4.0.0.0...
    What have I missed?

    Edit: Ok, there's another section of the docs about platform specifics. Hopefully that holds the answer.

    Edit again: Yep, it does indeed.
     
    Last edited: May 28, 2016
  24. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    Did you follow the directions for installing support for Windows UWP applications? http://guavaman.com/projects/rewired/docs/SpecialPlatformSupport.html#windows-uwp
     
    angrypenguin likes this.
  25. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,619
    No, I hadn't even realised they were there yet. Naturally as soon as I found them and started following them then a dialog popped up and told me about them.
     
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    The dialog pops up when you actually switch build platforms. If you are in Windows Standalone mode and just select the Windows 10 UWP platform and then press build, you haven't switched to UWP platform mode and there is no way I can detect that happening and pop up a dialog to offer to install the libraries before it tries to build.

    Regardless, the error you are reporting is not the same error I see when the Rewired libraries haven't been installed. Without the libraries installed, it just complains about missing Rewired classes, not System.Runtime. The error looks like one that I see in a lot of posts about Xamarin when I search on Google and it was reported on the bug tracker for Unity in an older version.
     
  27. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,619
    I was definitely switched to the UWP platform, but I may have done that prior to bringing in Rewired.

    In any case, I was more pointing out that the system was indeed trying to help. The popup was when I selected Install Platform Support -> Windows 10 Universal, which I'd clicked on by way of the very instructions it was referring to. There are a couple of steps after that, so referring people back to the docs from there isn't at all a bad thing.
     
  28. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    Yes, that would cause it not to pop up as well -- being in UWP before importing Rewired. It does the check upon build mode switching.

    Did the error go away?
     
    angrypenguin likes this.
  29. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,619
    Yes, it did.
     
    guavaman likes this.
  30. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    Good! Odd that the error was different than what I was seeing. Can't think of any reason why it would say System.Runtime is missing. Oh well. It works and that's what's important.
     
  31. beNice

    beNice

    Joined:
    Sep 12, 2014
    Posts:
    28
    Man, you've thought of everything.

    Not only did that work but "The Easy Way" also seems to work with all PlayMaker scripts!

    Is there any overhead to using the UnityInputOverride way?
     
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    As long as the script calls Input.xxx and not UnityEngine.Input.xxx, it will work.

    Yes. The overhead is an additional 2 function calls and a couple of ifs per Input.xxx call.
     
    Last edited: May 28, 2016
  33. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
  34. willpower

    willpower

    Joined:
    Oct 6, 2013
    Posts:
    53
    Hey there,

    I've been using Rewired for quite a while (it's awesome!) and just updated from version 1.0.0.82 to 1.0.0.87. Controller input stopped registering on game side and after some digging found that I can no longer uncheck the "Update" box under Update Loop in the settings. Is this intended behavior now?

    Thanks!
     
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    Yes it is intentional. It is because input will not work correctly in Unity UI if Rewired is not updated in the Update loop as well as some other reasons for possible future additions. This would not cause your controller input to stop working however.
     
    Last edited: May 30, 2016
  36. vjekoslav89

    vjekoslav89

    Joined:
    Sep 25, 2015
    Posts:
    2
    Hi,
    I don't know if someone already asked this question, but it's hard to search through 42 pages for an answer. I have the following problem. I'm doing conflict checking with (simplified) code below:

    Code (CSharp):
    1. foreach(ControllerPollingInfo info in ReInput.controllers.Keyboard.PollForAllKeys())
    2. {
    3.     ElementAssignmentConflictCheck conflictCheck = new ElementAssignmentConflictCheck(...);
    4.     bool conflict = ReInput.controllers.conflictChecking.DoesElementAssignmentConflict(conflictCheck);
    5.     if (!conflict)
    6.     {
    7.         // Assign new key
    8.         map.ReplaceElementMap(conflictCheck.ToKeyboardKeyAssignment());
    9.     }
    10. }
    But if I have at least one ActionElementMap that doesn't have a key assigned to it (Key.None), function will always return true, as if it is conflicting with that element. Is that a normal behaviour? Is there a way of telling DoesElementAssignmentConflict function to ignore elements that don't have a key assigned to it?

    Thanks,
    Vjekoslav
     
  37. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    If ElementAssignment.keyboardKey == KeyCode.None, it will be treated as a button assignment and instead it will compare ElementAssignment.elementIdentifierId. If it finds anything with that elementIdentifierId, presumably 0 if you left it that way, it will conflict. Passing an ElementAssignment that has no valid key mapping is an invalid operation should not be done.

    If an existing ActionElementMap has KeyCode.None and you are passing a valid ElementAssignment in such as for KeyCode.Space, it will not conflict with the existing KeyCode.None assignment. (Tested and verified using ControlRemappingDemo1.)
     
  38. vjekoslav89

    vjekoslav89

    Joined:
    Sep 25, 2015
    Posts:
    2
    This is the part that's not working to me. I'm not trying to assign KeyCode.None, I'm trying to replace existing one. But the problem is, if some ActionElementMap had KeyCode.None assigned from the begining (from Rewired Editor), I would get conflict.
    If all ActionElementMaps have valid key code set from editor and I later assign KeyCode.None to some element and after that I check for conflict using some new arbitrary keycode, the confict will not occur. Can you confirm this kind of behaviour?

    Why is this true? For instance, it's not that uncommon for a game to have a primary and a secondary shortcut for the same action, but sometimes, not both shortcuts are used. How would you implement this scenario then?
     
  39. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    I have already confirmed that it does not conflict yesterday. Can you send me repro example?

    Edit: My testing yesterday involved creating an invalid (blank) ActionElementMap from the Rewired Input Manager, but this does not work to test this issue because that invalid map is filtered out when Rewired initializes and creates the mappings in the Players. See the next post.

    Why would you ever want to conflict check an assignment of nothing? This makes no sense. If you're creating an assignment to nothing, you either delete the ActionElementMap or just add it as an ActionElementMap with no target. There would never be any purpose to conflict checking an assignment of nothing because it can't possibly conflict with anything. Just add it without checking.
     
    Last edited: May 31, 2016
  40. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    @vjekoslav89

    I have been able to reproduce your issue. Here is the reason:

    When you create a blank ActionElementMap or clear an existing one to blank, the elementIdentifierId is set to 0 instead of -1.

    When you do a conflict check against a blank ActionElementMap in a Keyboard Map, the conflict checker cannot determine that the ActionElementMap is a keyboard mapping (because ActionElementMap.keyboardKeyCode is set to KeyboardKeyCode.None) and therefore treats it like any other Button ActionElementMap. ActionElementMap does not store ElementAssignmentType and therefore cannot differentiate whether it is a Keyboard mapping and only knows that it is a Button mapping. A determination of whether it is a keyboard or regular button mapping happens by checking whether keyboardKeyCode == KeyboardKeyCode.None. If it is none, it is treated as a normal Button. If it is not None, it is treated as a keyboard key. Since it thinks it's just a normal button because it found ActionElementMap.keyboardKeyCode = KeyboardKeyCode.None, it then checks the elementIdentifierId (used for normal buttons, not keyboard keys), finds a 0 there, and then checks that against incoming assignment conflict checks, which for keyboard maps also have an elementIdentifier of 0. The conflict is triggered on the elementIdentifierId.

    This can only happen if you create a blank ActionElementMap with a script at runtime. When you create a blank assignment in the Rewired Input Manager for a particular Controller Map, Rewired does not generate that blank (invalid) assignment at runtime when it creates the Controller Maps and Action Element Maps -- the blank mapping is skipped. By manually creating one with a script, you can then run into this conflict issue.

    The solution is to not create blank ActionElementMap assignments and instead delete the ActionElementMap when it is no longer used. This is what Control Mapper and ControlRemappingDemo1 do -- neither of those examples leave invalid ActionElementMaps lingering in the Controller Map when removing an assignment.

    I will make changes to the ActionElementMap class to set the elementIdentifierId of a keyboard assignment to -1 instead of 0 which would prevent this conflict checking issue, but the recommended way of handling this is to delete blank ActionElementMap instead of setting its keyboardKeyCode to KeyboardKeyCode.None.

    A workaround, albeit a bit odd, would be to manually set the new blank ActionElementMap's elementIdentifierId to -1 after it is created.
     
    Last edited: May 31, 2016
  41. OneThree

    OneThree

    Joined:
    Oct 28, 2011
    Posts:
    181
    Is there any chance of having support for curves added?

    It seems like it'd be pretty quick to add by using an AnimationCurve variable. You could just take the existing sensitivity float and multiply it by AnimationCurve.Evaluate(), which returns a float.

    Could literally be done in one line of code (in addition to the `public AnimationCurve sensitivityCurve` declaration).
     
  42. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    It's not that simple if I were to add complete support and not just an API method:

    1. The AnimationCurve would need to be serialized to XML and saved along with the Calibration Map.
    2. Control Mapper would need to be updated to support animation curves.
    3. An entire editor system would need to be created to allow you to set override curve values for each individual joystick element on each joystick Rewired supports, otherwise you'd have to detect the joystick type in code and manually determine which axis to set these curves on. No such interface exists at present for overriding hardware element settings as the Rewired Input Manager is a mapping editor, not a hardware setting editor.
     
  43. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    I have just tried to implement the Input Override script.
    I have it added all the "same name" actions and there are no more warnings or errors.
    At this stage I have only added a couple of mappings to test eg. "Fire" to both keyboard and mouse

    Nothing seems to happen. Do I need to add all mappings before it works or should I be seeing this single test mapping work at this stage?

    This is Unity 5.3.4p6

    Update:
    Ah.. never mind.. Just me not reading far enough down the page. Working now thanks.
     
    Last edited: Jun 1, 2016
  44. DiscoFever

    DiscoFever

    Joined:
    Nov 16, 2014
    Posts:
    286
    Maybe a dumb question but anyway; all these settings, mappings, etc. How do i "save" / "export" them ? If i need to use the same exact settings in another project, how do i do ? Pretty obvious but I couldn't find out where this was explained.

    Thanks and sorry for the dumb question ;)
     
  45. acgleader

    acgleader

    Joined:
    Apr 17, 2013
    Posts:
    40
    Can you support it in future
     
  46. idavida

    idavida

    Joined:
    Nov 12, 2012
    Posts:
    33
    I've just started using Rewired and it really is as awesome as everyone says. I do have one question I can't find a solution to. It is probably just me not thinking clearly, but I can't seem to find a way to use both Left and Right Trigger on a Xbox360 controller as ButtonDown linking to only one action. Only one action since I dont want two "Fire" actions (fire1, fire2) in my remapper.

    Quite simply: I want to use both triggers simulating ButtonDown as one action. How..? :)
     
  47. raithza

    raithza

    Joined:
    Dec 14, 2011
    Posts:
    21
    Hi,
    We've recently introduced Rewired into our game Broforce and while it's solved a lot of problems for us it's created a couple more. Specifically, some people with "weird" controller/OS setups are finding that they cannot bind their controls in our mapping screen due to some axes always always returning a nonzero value.

    You can see some of the user complaints here: http://steamcommunity.com/app/274190/discussions/0/357287304421387832/

    Due to us introducing Rewired at such a late stage in development we're not quite following the standard Rewired paradigm, but in any case, is there a way for me to calibrate axes so they are useable?
     
  48. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    Input Manager - How is Data Stored

    "Unlike most input systems, Rewired does not store its input configuration data (maps, Actions, etc.) in a single location for the entire project. Instead, the data is stored in the current Rewired Input Manager game object. This means that you can have entirely different input setups for different scenes in your project if you like because each Rewired Input Manager is completely separate. It also means that input data is not globally available, especially in editor scripts or when Rewired has not been initialized."

    "At runtime, the current input configuration is loaded from the active Rewired Input Manager in the scene. To change to a completely different input configuration, you can disable one Rewired Input Manager and enable another in the editor. (Make sure you only have one active any any time or all others will be disabled.) The Rewired Input Manager can also be made into a prefab and instances placed into each scene for a shared configuration."

    --------------------------------------------------

    Rewired uses Unity's serialization system and stored the data in the GameObject / prefab. You treat it like any other object you would in Unity. Copy and paste it to another project, or copy the .asset/.scene file along with the .meta, or export to Unitypackage and import in the other project.
     
  49. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    That depends. Framerate-independent input requires major changes to the entire structure to get and track queues of input events in a separate thread. This would require adding native libraries to handle keyboard, mouse, joystick, and touch input on all platforms -- a very, very large task. (Currently only certain platforms use native libraries for joystick input only, all use Unity input for keyboard, and only Windows has the option of native mouse.) In addition, it would be significantly slower than the current system because events would have to be tracked and created at several points along the way because of Rewired's Action-based system -- hardware element events from multiple sources would have to be analyzed and converted into simulated Action events per Action, per-Player. This does add significant overhead based on past preliminary implementation work. Finally, the ultimate result of these major changes would simply be to allow you to access a queue of Action events that took place over the last frame for analysis and not the ability to instantly respond to events between frames. If you were to use any of Unity's API to respond to an event that was triggered between frames on another thread, Unity would crash because the Unity API is not thread-safe.
     
    Last edited: Jun 1, 2016
  50. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    I'm not sure exactly what you mean. Is it one of these two?

    1. When either L or R is pressed, GetButtonDown should return True
    2. Only when BOTH L and R are pressed, GetButtonDown should return True
    If #1, all you have to do is assign the same Action to both L and R. However, if L is currently held, pressing R will not cause another ButtonDown event because it is the same Action and the "button" referred to by GetButtonDown is the simulated Action button which would still be considered held if either trigger were being held.

    If #2, this is not possible directly within Rewired. You would have to assign two different Actions and code something to handle this:

    Code (csharp):
    1. if(player.GetButton("Action1") && player.GetButton("Action2")) {
    2.    // do something
    3. }
    You would also have to keep track of the Down state of your new simulated button yourself in code.
     
    Last edited: Jun 1, 2016