Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Rewired - Advanced Input for Unity

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

  1. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    The G27 racing wheel has a large number of buttons defined for it. I was expecting it to be much less than that. It almost looks like some of the Flight Simulation controllers.

    Rewired_G27_wheel.JPG
     
  2. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Excellent! There are others who are looking for UFPS integration which I'm planning to work on in January hopefully, so I'm glad to hear you were able to do it. Though I see you've done it by modifying the UFPS code, which I need to try to avoid if possible. How many classes did you end up having to modify?

    Short answer: Enable XInput

    Bumper Bottom being the Triggers? And I'm guessing this is an Xbox 360 gamepad then. It sounds like you've disabled XInput, because unless you're using XInput on Windows, the two triggers on the X360 gamepad act as a single axis making it impossible to press both simultaneously. Left = -1, Right = +1, both = 0. This is the way MS chose to expose the data in the HID report of the gamepad. There is one single byte for the combined axis 0x00 -0x FF, with 0x80 being at rest. XInput is able to treat these axes as separate and detect simultaneous presses, but Direct Input and Raw Input are not.

    Interestingly, up until a certain version Unity's input system also did not separate these and you can see they added 2 extra axes to the controller (8 and 9) in a later version that separated the axes though they don't always work according to my tests and other's tests depending on which Unity joy id the controller shows up as. After working with the 360 pad's HID data myself, I'm certain that Unity hacked in special case code for the Xbox 360 pad and is somehow getting the data from some other source than the USB HID report (probably the USB device directly, essentially making their own driver) because that data is simply not separable. Just how they are doing this I do not know at this point and their implementation is flawed because it has problems supporting more than 2 controllers simultaneously.

    This issue extends beyond Unity and Rewired:
    http://en.sfml-dev.org/forums/index.php?topic=11933.0
    http://ngemu.com/threads/xbox-360-controller-lt-rt-fix.157181/
    http://forum.kerbalspaceprogram.com...Xbox-360-controller-Triggers-and-DPAD-mapping
    http://en.wikipedia.org/wiki/DirectInput#DirectInput_vs_XInput

    Reading those links, It appears it's caused by the official Windows Xbox 360 driver itself and it was an intentional decision so as to show each trigger at a 0 state instead of a -1 state by default.
    All that said, the simple solution is to enable XInput in the Rewired Input Manager.

    I've added this question to the Troubleshooting page of the documentation.
     
    Last edited: Dec 14, 2014
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Yeah, it's crazy the number of inputs on the G27. Most of them are on the shifter console. There's no way you could fully map this device using Unity input or any input manager that relies on Unity's input system because of the 20 button limit.
     
  4. ge01f

    ge01f

    Joined:
    Nov 28, 2014
    Posts:
    121
    Awesome. This looks like the answer. I was playing with an Xbox 360 controller for PC (should have mentioned that, and probably OS and such too...).

    I just tried it with a Logitech dual stick controller and it totally worked.

    The reason I turned off Xinput is that I got a "DllNotFoundException: xinput1_3.dll"

    Im not sure if this was supposed to be bundled with Rewired, or if Im supposed to copy a DLL somewhere (didnt see that in the instructions).

    Im running Windows 7, 64-bit, latest patches with DX11.

    Whats your suggestion for the missing xinput1_3.dll? Id prefer to solve it in the way that will work with future versions of your code on different machines instead of just doing it manually each time.


    This would definitely not be the first time they pulled shenanigans like this.

    I'll email you my changed files. All the changes map closely to the actions I already set up, and essentially change "vp_Input.GetButton" to my "rewiredPlayer.GetButton" and 'vp_Input.GetAxisRaw("Mouse X")' to 'rewiredPlayer.GetAxis("Look Horizontal")'

    I dont know if the UFPS people made their input manager API capable, but if I picked slightly different Action names they would almost completely line up.


    With my current project Im going to be integrating a number of different control systems together, and Rewired will be a large part of that, since it unifies all the control schemes.

    My current plan is integrating these assets:

    - UFPS + acParkour: Bipedal movement (Now working)
    - uFS Flight System Engine: In atmosphere flight sim
    - SPACE for Unity: Small ship control in outer space. (I might end up just using uFS for these controls and mixing in Space Graphics Toolkit, depending on how flexible uFS flight for space feels.)
    - Helicopter controller: In atmosphere heli system
    - A driving system. Poking around with AC Quick Vehicle Editor, Edy's Vehicle Physics and Realistic Car Controller to see which one seems the best fit.
    - A boat controller, which I havent found yet
    - Inventory and magic system ala RPG/Skyrim/Morrowind
    - Standard menus and option nav

    Rewired seems like it's going to handle all these transitions really well with Actions and Categories.

    It would be cool to get some collaboration/sharing going with anyone else who wants to do this, since I am trying to keep my pure coding to a minimum with this project to keep it fast and fun (I code for work, and this is play).
     
  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    You're missing the DirectX End-User Runtimes (June 2010). This is mentioned in the docs in the Installation, Deployment, and Troubleshooting pages:

    http://guavaman.com/projects/rewired/docs/Installation.html
    http://guavaman.com/projects/rewired/docs/Deployment.html
    http://guavaman.com/projects/rewired/docs/Troubleshooting.html

    Alternately, you can probably drop the xinput1_3.dll in the project folder and build folder, but I'm not sure about the legality of distributing this DLL directly like that.

    Okay, thanks a lot! I'll look at these in the coming days as my current workload lightens up.

    Wow, that sounds like one ambitious game! Rewired's categorization and mapping system should really help there. I'd love to see it when it's ready. Feel free to post updates or questions here on integrating all these assets.
     
  6. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    That is greate news on your Rewired integration with UFPS!

    DirectX 2010 run-time is a required installation. Just sticking in that single DLL ( xinput1_3.dll) does not solve the problem in all cases. It is easier for everyone to just install the DirectX run-time.

    There should be many people interested in integrations with those assets you listed.

    The author of uFS is working on helicopter flight simulation asset (uFS Helicopter) which is in private beta based on this message http://forum.unity3d.com/threads/unityfs-flight-simulation-toolkit.171604/page-6 (see msg #286). I did not know there was another asset already available for that.

    Are you planning on using controllers other than the XBOX-360? (e.g specific Flight Simulation Controllers?)
     
  7. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    For UFPS did you look at integrating within this file:

    Ultimate_FPS\Assets\UFPS\Base\Scripts\Core\Utility\vp_Input.cs
     
  8. electroflame

    electroflame

    Joined:
    May 7, 2014
    Posts:
    177
    This is pretty much the only file that will need major changes. In my case, I made my own input class (pretty much copied vp_Input) and switched out the input API calls for Rewired. Then wherever there were calls to vp_Input (pretty much the controller and camera, if I remember correctly) I just substituted vp_Input calls for my custom input class.

    Super simple, and took maybe a half hour to set up.
     
  9. ge01f

    ge01f

    Joined:
    Nov 28, 2014
    Posts:
    121
    Yeah, this looks like the better place to do the integration. I just stuck it in where it was used.
     
  10. ge01f

    ge01f

    Joined:
    Nov 28, 2014
    Posts:
    121
    Cool, not sure why it was missing for me then. I'll poke around.


    .
    Thats great, cause his Plane system is by far my favorite. The helicopter one I have now is pretty good, but if it was uFS complete it would be better.

    Im planning on mostly doing all the controls with dual sticks, since I like action games instead of sims.

    I'd like to get the STEM system when that comes out too, for Oculus VR stuff. I also got the Leap Motion stuff with that but havent gotten it integrated yet.
     
  11. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    The problem is Microsoft has no less than 3 versions of XInput. You can read about it here: http://msdn.microsoft.com/en-us/library/windows/desktop/hh405051(v=vs.85).aspx

    Long story short: For the Windows Standalone build target, Rewired uses XInput 1.3 for maximum compatibility with old versions of Windows and for maximum feature set to distinguish Gamepads from other types of XInput controllers (Guitars, Wheels, etc.). XInput 1.3 requires you install the June 2010 Direct X runtimes. Windows 7 and 8 come with their own versions of XInput, but they only support a limited subset of XInput 1.3 features (gamepads only).
     
    Last edited: Dec 16, 2014
    Arkade likes this.
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Good information! I'll definitely use this when I work on UFPS integration in Jan.
     
  13. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Great information.

    Just want to make sure we are all working in the same location. This is for UFPS v1.4.8+ to be clear for those just reading.
     
  14. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Hopefully there will be more info coming on uFS Helicopter soon.

    Have you done any integration with uFS v1.0.4 yet? I was just looking at these files in particular.

    ufs_flight_sim\Assets\UnityFS\Scripts\Editor\InputEditor.cs

    ufs_flight_sim\Assets\UnityFS\Scripts\Helpers\InputController.cs

     
  15. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    What is STEM I am not familiar with that. I usually think of STEM = science, technology, engineering and math.

    Are you specifically only on the Windows platform or are you doing other platforms as well?
     
  16. Shiratori

    Shiratori

    Joined:
    Aug 27, 2014
    Posts:
    21
    STEM is the latest controller being made by Sixense, the people behind the technology being used in the Razer Hydra. I'm waiting for my own as well.

    http://sixense.com/wireless
     
  17. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    It seems the Rewired Standalone Input Module posted in this thread for UnityUI no longer works. I've created a new version with the latest source code that now works again. Download it below:

    Usage:
    Create an EventSystem
    Click the EventSystem and disable the StandaloneInputModule in the inspector
    Add the RewiredStandaloneInputModule component to the EventSystem
    Choose which Player Id(s) will control the UI
    Set up Actions in the Rewired Input Manager for the "Horizontal", "Vertical", "Submit", and "Cancel" actions used by the module. (Change these names in the module if you like.)

    It should work just like when using Unity's StandaloneInputModule but will draw the input from the Rewired Player(s) instead.
     

    Attached Files:

    p87 and Arkade like this.
  18. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Thanks for the clarification.
     
  19. Situacao

    Situacao

    Joined:
    Dec 4, 2013
    Posts:
    21
    Hey guavaman, got a quick question here regarding Rewired and the 4.6 UI.

    Does the RewiredStandaloneInputModule allow different players to access the UI at the same time? Like what happens, for instance, on fighting games, where you have two players acting independently on a single character select screen?

    Thanks in advance!
     
  20. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    The only changes to the RewiredStandaloneInputModule is the source(s) of input. Unity designed that module to essentially be for one player and I didn't add anything to change that. If you assign multiple players to control the UI, the only thing it will do is allow input from all controllers connected to those players to affect the UI. IE: If 4 players are assigned and pressing directions, they'll be fighting for control of the UI. It wouldn't be suitable for a multi-player character select screen without modification.
     
    Last edited: Dec 18, 2014
  21. bkw

    bkw

    Joined:
    Sep 20, 2013
    Posts:
    49
    When and how is the keyboard assigned to a player? Is it always assigned?
    I want to know if a player has any controllers assigned to it (so I can include that player in the game). I'm looking at player.controllers.Controllers, but the keyboard seems to be assigned to all players.
     
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    The keyboard is by definition a shared controller and never has to be assigned. So all you have to worry about is which keyboard maps are assigned to which players.

    Mouse is only assigned to players by manually checking the assign to player on start checkbox in the Player in the editor.
    Joysticks are only assigned to players if you have the auto assign settings configured in the editor.
    Custom Controllers are only created and assigned to a player on start if configured to do so in the Player page.

    All can be manually assigned and de-assigned via scripting.

    If you're trying to find out which joysticks are assigned to a player, just use player.controllers.Joysticks.

    API docs for Player.ControllerHelper.

    There are also a bunch of controller related methods in ReInput.controllers:
    http://guavaman.com/projects/rewired/docs/api-reference/html/T_Rewired_ReInput_ControllerHelper.htm
     
  23. bkw

    bkw

    Joined:
    Sep 20, 2013
    Posts:
    49
    So I presume that ClearAllControllers will clear the Keyboard controller as well?

    Some more questions...

    Are controller ids unique between controller types? Do I need to compare both controllerTypes and controllerIds to see if they're the same, or is id sufficient?

    If a joystick is disconnected and reconnected, it's not guaranteed to have the same controller id right? (Don't know if there's some unique Id in the hardware, but I assume no...)

    Also, with calls like ReInput.controllers.IsJoystickAssigned(), in general, is the SystemPlayer included? ReInput.players.AllPlayers and ReInput.players.Players was a little confusing, in terms of naming.

    Thanks!
     
  24. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    No it won't. Keyboards are not assigned, therefore cannot be unassigned.

    If you want to clear keyboard maps from a player, use player.controllers.maps.ClearAllMaps or player.controllers.maps.ClearMaps.

    Use the type and ID. They are unique per type.

    There is no guarantee. Rewired will try to find the last controller matching that description that was connected and assign it back to the same ID, but there are cases where that may not happen. If it can't find a match in the history, it will generate a new Controller object and give it a new ID.

    Yes, the System Player is included. If the method doesn't include the system player by default, it will have an an overload to include it.

    I chose to organize the different categories of methods in helper classes to make it less confusing than having to sort through potentially hundreds of methods in a single mega class for ReInput and Player. It also makes finding things via intellisense a whole lot easier somewhat at the expense of browsing the documentation.
     
    Last edited: Dec 19, 2014
  25. bkw

    bkw

    Joined:
    Sep 20, 2013
    Posts:
    49
    Ok, so I assume that unplugging/plugging keyboard and mouse don't trigger connected/disconnect events and unassignment/assignment either then? Working on a laptop right now, so I can't quickly test it. =)

    Awesome. Thanks for the help and making the package. I think I'm getting the hang of things now.
     
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Correct. Only "joysticks" (or other devices that fall under the same category like racing wheels, etc.) will trigger connect/disconnect events.

    You're welcome and thanks! I hope you like it and get a lot of use out of it.
     
  27. Arcanor

    Arcanor

    Joined:
    Nov 4, 2009
    Posts:
    283
    Thanks for providing such a great package!

    I have a question about input polling. I've created the usual "Vertical" action as an Axis. It's working fine. I've assigned some keymaps to it; the usual "WASD". They're working fine too. I've also created an "Autorun" toggle action, with a keymap (mapped to "F"). This is also working fine.

    Where I'm running into a problem is when toggling Autorun off via an alternative method. If I hit "F" again it toggles off as expected. What I'm trying to do is additionally have Autorun toggle off if 'W' or 'S' are pressed. So I've added a GetButtonDown("Vertical") to my code. Since "Vertical" is an Axis action and not a Button action, it's not giving me the result I'm hoping for. What's happening is that it is triggering ONLY if 'W' is pressed (i.e. the Positive action for the Vertical axis), but if 'S' is pressed (i.e. the Negative action for the Vertical axis) it does NOT trigger. Is this a bug, or do I need to work around it by creating additional actions?

    Thanks in advance.
     
  28. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    Hi, had a question about GetFirstElementMapWithAction. I've been using it since guavaman answered my question about how to display on-screen input "glyphs" for various controllers (like PS3 vs 360). It's been working great for individual buttons, but now I've got a situation where it's not working with an axis.

    I've got a single action called "Map Zoom" set up as an axis with the Positive Name "Zoom In" and the Negative Name "Zoom Out."

    On gamepads I've got the equivalent of L2 and R2 mapped to zoom in and out, on keyboard it's + and -, and the mouse wheel is also mapped. Everything's functional, but I can't seem to get the individual positive and negative control names using GetFirstElementMapWithAction. If I pass it the action name "Map Zoom" I get just the positive part of it. I was hoping I could pass in "Zoom In" as the action name or something like that, but that didn't work. That's not actually an action name, so I guess that makes sense.

    Should I split this into two separate axes or is there some way to get the individual controls for the current joystick and keyboard? It doesn't really feel like something that needs two axes, but if that's the best solution, I can live with that. Thanks!
     
  29. bkw

    bkw

    Joined:
    Sep 20, 2013
    Posts:
    49
    Question about unsupported controllers, or controllers without maps.

    Currently I have only defined maps on the Dual Analog Gamepad template. This works great for Xbox and Playstation controllers, and let's me "share" the common map between those controllers. I want to somewhat support controllers that don't have a hardware joystick map, and if I understand how things work, these controllers will be "assigned" the Unknown Controller hardware map. Since Unknown Controller doesn't / can't conform to the Dual Analog Gamepad template, I'll need to define a controller map directly on Unknown Controller. Is this correct?

    With controller maps defined on the Dual Analog Gamepad template and Unknown Controller, this will cover most controllers?
     
  30. p87

    p87

    Joined:
    Jun 6, 2013
    Posts:
    318
    Question - is NVIDIA SHIELD controller supported?
     
  31. Arcanor

    Arcanor

    Joined:
    Nov 4, 2009
    Posts:
    283
    One additional question... I have my input database setup in one scene. When I start another scene there's a blank database again. How can I copy the database between scenes so I don't have to re-enter all the settings?
     
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Hi,

    The Button state only returns true if the underlying float value is positive. Negative Button is activated by negative values. Use player.GetNegativeButtonDown() instead.
     
  33. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    The problem here is that you are using the GetFirst method when you have two elements mapped to the same action. Just use the methods that enumerate all matching elements.

    http://guavaman.com/projects/rewire...lerHelper_MapHelper_ElementMapsWithAction.htm
    http://guavaman.com/projects/rewire...rollerHelper_MapHelper_AxisMapsWithAction.htm
    http://guavaman.com/projects/rewire...llerHelper_MapHelper_ButtonMapsWithAction.htm

    This class has everything you need:
    http://guavaman.com/projects/rewire...Rewired_Player_ControllerHelper_MapHelper.htm
     
  34. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Creating a map for Unknown Controller can be done, but realize that this may or may not provide a sensible starting layout for your users depending on their controller(s). Unknown Controller just provides 32 axes and 128 buttons for you to map actions to, but there is no way possible to know what controller elements these will get assigned to on an unknown controller type. That's why it's important to provide your users a user remapping screen where they can customize their controller mappings. The Unknown Controller map can provide a possible starting point, but that's all.

    There are many other controllers in Rewired that are not covered by those two maps alone. The G27 racing wheel, the CH flight products, the Logitech Extreme 3D Pro, light guns, etc. all have controller definitions (HardwareJoystickMaps) but do not inherit from the Dual Analog Gamepad template. These devices should have maps created for them if you expect many users to be using them. If not, you can let the users map them themselves. Controllers with definitions will not use the Unknown Controller map.
     
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Not as a controller with a definition currently but it will be. I have a Shield and a Shield Tablet with gamepad to map after the new year.
     
  36. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Make a prefab out of the Rewired Input Manager or copy and paste the Rewired Input Manager to the next scene. All the data is stored as serialized data in that MonoBehaviour. If you do make a prefab out of it, make sure you edit the prefab and not the one in the scene when making changes or else your other scene won't inherit the changes.
     
  37. p87

    p87

    Joined:
    Jun 6, 2013
    Posts:
    318
  38. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    Ah, I missed that somehow. Thank you, that's exactly what I'm looking for. All I need to do is grab the list and spin through to find axisContribution "Positive" or "Negative." Should have known it was going to be easy.
     
  39. Arcanor

    Arcanor

    Joined:
    Nov 4, 2009
    Posts:
    283
    Thanks on both counts! I missed that GetNegativeButtonDown() function in the API. It's now working fine.
     
  40. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027
    Wish I could search the documentation ;)

    Haven't bought it yet, but I'm curious how the framerate-independent input would be implemented in Unity (keyboard and mouse). Is it dependent on the Update Loop setting in Rewired Editor? Like if we want to poll input 120 times per second, we would set the appropriate fixed timestep, set Rewired's update loop to fixed update and read the input in FixedUpdate?

    edit: I guess using the event system would work for keys? What about mouse input?

    edit: and is there an ETA for Native Mouse Handling support for OSX?
     
    Last edited: Dec 23, 2014
  41. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
  42. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Thanks!

    I'm aware the search feature in the documentation doesn't work. Sandcastle is the documentation generator I used and the search function seems to require ASPX support which my Linux server does not provide. The best you can do for now is to use Google and search with site:guavaman.com/projects/rewired/docs.

    No ETA on native mouse handling on OSX. The only reason it was implemented on Windows was because of a rather serious bug that happens when plugging and unplugging joysticks many times. As far as I'm aware, that bug doesn't exist on OSX. Otherwise, the only reason to add it would be for framerate independent input which will hopefully be done in January.

    The plan for framerate independent input is to record precise input event timings which can be read during a normal update loop. You would then be able to read the events that took place between the last update and the current update and decide what to do with that information. It won't be possible to act on input events immediately as they occur because they will be taking place in a separate thread. The input thread update frequency will be configurable however. FixedUpdate won't have anything to do with framerate independent input as it's not a true fixed frequency update and it runs on the same thread as Update.
     
  43. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027
    That all sounds great! I was stressing about writing my own native input solution (mostly for mouse, but also for keyboard) so it'd be really nice if Rewired can lift the burden. Looking forward to January :)
     
  44. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Unfortunately, keyboard input is handled through wrapping Unity's Input.GeKey functions at present, so framerate independent input won't apply to keyboards if/until I implement native keyboard handling.
     
  45. electroflame

    electroflame

    Joined:
    May 7, 2014
    Posts:
    177
    I ran across an edge case here that might be of note.

    Currently, Rewired, when destroyed, does not stop all controller vibration (which means that your controller vibrates until you boot up something that kills vibration (if you closed the application) or you load up another instance to Rewired and stop it manually). Interestingly, it seems like when the application is closed, Rewired is one of the first things to get destroyed (which makes it extremely hard, if not impossible, to manually stop vibration before all references to Rewired are null).

    I'm curious if this would be a good thing for Rewired to support out-of-the-box, or if it should be up to individual devs to implement. Normally I'd say it should be up to us devs, but I'm racking my brain trying to think of a case where this wouldn't be something beneficial for Rewired to do on its own.

    Any thoughts?
     
  46. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Hi EF,

    Thanks for discovering that. I will make it stop all XInput vibration as part of the destruction process.
     
  47. electroflame

    electroflame

    Joined:
    May 7, 2014
    Posts:
    177
    Awesome, thanks! I wasn't sure if I should bring it up, but I'm glad that I did. Great support, as always!
     
  48. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Rewired 1.0.0.20 is available for download for registered users now on the website. If you've bought Rewired and want to get access to the latest downloads immediately, contact me with your email address.

    1.0.0.20 release notes:
    More updates will be coming soon. Things have been a little slow due to the holidays.
     
    BuckeyeStudios likes this.
  49. TheOz

    TheOz

    Joined:
    May 21, 2011
    Posts:
    34
    Hello Guavaman,

    Rewired is a great product. I am currently using it in one of our latest game development projects. I am running into one problem that I need advice on how to set up. based on your examples I set up input on a player gameobject. when he dies the gameobject id destroyed and then recreated. when he is recreated I get the following error:

    More than one Rewired Input Manager was found in the scene! Only one Rewired Input Manager may exist in a scene. Input will be disabled.
    UnityEngine.Debug:LogError(Object)
    Rewired.InputManager_Base:‫‭‬‫‌‬‪
‌‌‌
‍‌‎‎‭‌‍
‮‬‮(Object)
    Rewired.InputManager_Base:IsOnlyManagerInScene()
    Rewired.InputManager_Base:Initialize()
    Rewired.InputManager_Base:Awake()

    on this line:
    player = ReInput.players.GetPlayer(playerId);

    player is set out of the "Awake" function during the creation of the player gameobject in the playercontroller script
    is there a way to set this up so the player set above is available globally so I only have to set it ones from another gameobject?

    Garry Osborne
    Game Developer
    Crazy Beard Entertainment

    UPDATE: figured it out. found that I was reloading the level on his death, old code I had left in, and had the do not destroy on load for the rewired input manager. so it was keeping the inputmanager and trying to load another one when the level loaded. Doesn't seem to work right as I was thinking the do not destroy flag if your loading the same level the input manager is contained in. maybe you can throw a warning rather than an error in this case?
     
    Last edited: Dec 31, 2014
  50. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    The only way you would be getting this error is if you are instantiating a 2nd Rewired Input Manager in the scene. This is not allowed. Is your Rewired Input Manager contained inside the player game object that you're instantiating? If so, that's the problem. Your Rewired Input Manager should be in the scene at all times and not destroyed (unless you want to destroy it and create a new one when you load the next level for some reason.)

    As for the Rewired.Player reference, that's static and contained within Rewired.ReInput. When the line "player = ReInput.players.GetPlayer(playerId);" runs, it is just getting the Player reference, not creating the Player. The Player is created by the Rewired Input Manager on Awake when you first instantiate the Rewired Input Manager. It is done once and never again unless you destroy the Rewired Input Manager and instantiate a new one.

    I hope this helps.