Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Template Space Combat Kit (VSXGames) [RELEASED]

Discussion in 'Tools In Progress' started by Billy4184, Jul 14, 2015.

  1. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    6,049
    @Steve-Tack please remove or deactivate the 'PlayerSpaceFighterControl' and 'PlayerGeneralControl' child gameobjects of the player before dragging in the Rewired prefab. I should have clarified this in the manual.
     
  2. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    Got it. That worked. All three controllers work properly and rumble still works. Thanks!
     
    Billy4184 likes this.
  3. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    6,049
    Glad to hear it!
     
  4. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Great news. Have you tried any HOTAS controllers yet?
     
    Billy4184 likes this.
  5. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    6,049
    @Steve-Tack some feedback on that would be great. I made maps for the HOTAS template, but I don't have any controllers that use it. Some of the buttons in the template were a bit ambiguously named (which isn't surprising given there's no standard format!) but I hope that I got things roughly right the first time.
     
  6. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    For HOTAS setups you will probably need to change the max joysticks per player from 1 to 10 to handle all of the different devices. For the simple case of stick, throttle and pedals being separate USB devices.

    If you add support for the Flight Pedals Template that is fairly standardized.

    What range are you using for throttle calibration mode? Are you using 0 to 1 or -1 to 1 mode?
     
  7. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    6,049
    The HOTAS template seems to cover all of the entry-level joysticks, such as the Logitech Extreme 3D Pro and the Microsoft Sidewinder. Those are what I'm aiming at with the integration - I'm interested in supporting key controls (such as the trigger, throttle, XYZ axes, and a few of the buttons that I think probably mean the same thing on most devices, such as base buttons 1 and 2). Beyond that, I am not going start mapping things to the 20th button or axis, because not only will many devices not have that many buttons, but it's anyone's guess which one you're actually mapping to on any given device.

    For games with out-of-the-box support for complex HOTAS devices, the dev will really have to make their own choices about how they will deal with varying number of controls.
     
  8. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    The Rewired HOTAS templates covers all joysticks from most basic like the basic ThrustMaster USB Joystick ($20) to the ThrustMaster WartHog ($500). The Stick X/Y, Trigger and POV HAT works across all of them with the HOTAS Template. The Z axis generally works for those that have a twist stick instead of pedals (which is most sticks). CH Products and the Warthog do not have twist stick so most are expected use flight pedals for Z axis. That seems like a nice general subset that covers everything.

    Many of the higher end HOTAS systems (Saitek X-56/55, CH FighterStick, Warthog) also have mode select switch. Typically that is three modes so that gives you three times the number of buttons available too. So yes it can be mapping madness or opportunity for those who enjoy it. :)
     
    Billy4184 likes this.
  9. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    Sorry been off the Net for a while I have an old Saitek X45 so I can test
     
    Billy4184 likes this.
  10. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    6,049
    That would be great!
     
  11. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    OK Fine but I am getting a' All complier errors have to be fixed before entering playmode ' Error
     
  12. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    Deleted my old version of Space Combat Kit as I had Rewired on there so I was thinking it might be that so starting of with a clean install see what happens there
     
  13. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    6,049
    Yes the new integration is only for version 1.21.
     
  14. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    Speaking of which I sort of got it working but I am having trouble with it spinning a bit could be me or my controller
     
  15. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    OK Thanks
     
  16. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    Billy, to be brutally honest with you you don't really need Rewired , what you really need to do is not hard code the mouse and keyboard controls only into Space Combat I would suggest just making the Input code very open , even to Unity's Joystick commands and then include Rewired , then game designers/Programmers can grapple with Rewired but you would have a way allowing Joystick H.O.T.A.S's gamepads, e.t.c that will be able to use Space Combat for controls. I have managed to do so with my hovertank ( flight controls though flight were something else and still working on that ) And I am not even half the programmer you are mate , hope this helps with this excellent package
     
  17. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,637
    You could do something like this:
    https://forum.unity.com/threads/rewired-advanced-input-for-unity.270693/page-69#post-3198553

    But you'll find there are going to be a lot of problems trying to use HOTAS devices with Unity's input system. The 20-button limit prevents buttons from working on just about every major HOTAS device. The simple flight sticks mostly work (ran into a couple with non-working axes), but true HOTAS setups are a problem.
     
    Billy4184 likes this.
  18. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    I guess it would be if it only has a 20 button input as my old Satiek X45 has at least 26 but for something like a Thrustmaster Flight X H.O.T.A.S the standard Unity joystick input would be enough (though it isn't that great) I would like to look at the manual for getting it to work with Space Combat as I am experiencing problems with it at the moment
     
  19. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449

    One thing though which command is for Yaw , Pitch and roll please? I only have horizontal and vertical commands here and tried most of them with very limited success , the throttle works fine though
     
    Last edited: Nov 29, 2018
  20. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,637
    Unfortunately, I can't help with Space Combat Kit because I didn't write the integration and don't know how it's been set up. (I don't have Space Combat Kit.) I'm sure @Billy4184 will be able to help.
     
  21. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    OK thanks
     
  22. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    6,049
    To make different control scripts for different vehicles, you just need to create a new script that implements the IVehicleInput interface, and add it to a child of the Player.

    The VehicleControlClass value on the script must then match the one that you have created for your vehicle. Then when your player enters the vehicle, it will find the first matching input script and run it.

    There's a reason I use interfaces, despite the fact that it can be a something inexperienced devs have never faced (although they are very straightforward to use once you learn about them). They are mainly for the benefit of a programmer, which must be balanced, in some cases, against the benefit to someone who would like to do things just in the inspector.

    With interfaces, input scripts for different vehicles can be entirely separated (as with subsystems, modules and so on). This helps immensely when dealing with code.

    But to make an input script that allows for generic mapping of input for any kind of vehicle, is likely to make programmer's lives a lot harder, because you'd either need to hardcode all the possibilities or you need to abstract the code to a very large extent. I'm not saying it's impossible. Perhaps it could be done reasonably well with a custom inspector that operated like Unity's Button component, and I might try something out eventually, but in the end I do not want the space kit to become something of an attempt to introduce code-less game development to Unity, as this is not just very difficult but far beyond the scope of what the kit is for.

    I'm making progress on the documentation (user guide) and I would like it to be very clear to people what they need to know in order to be able to deal with any part of the kit. But, especially when it comes to molding the kit for a slightly different usage, it's never going to be something where you never need to get into the code.
     
    guavaman likes this.
  23. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    @Vampyr_Engel you really cannot be effective with standard unity input with HOTAS systems. You have to consider the multi-platform (Windows/MAC/Linux) for HOTAS systems too. That is the other reason why Rewired is the standard it is. Just looking at the game Elite Dangerous' forums and you see the great interest is not just in low end HOTAS systems but higher end HOTAS systems too. In the Elite Dangerous forums you can see how many players are interested in trading up to higher end HOTAS systems and do so regularly. So we as developers need to have factored in high HOTAS systems from the beginning and not be scrambling because a customer upgraded their HOTAS equipment. Also you have to consider how many end users mix and match different vendors' gear to make their own "custom" HOTAS system. The customer may have Saitek flight pedals, CH FIghterStick, and use a Warthog throttle for example. So we have to consider those customers who will be upgrading their HOTAS gear either as individual pieces or as full sets as something we have to support from day one. That is not even counting issue of when customer wants to remap their controls within the game. That why I am happy to use Rewired to provide that solution for me.
     
    Last edited: Nov 30, 2018
    guavaman likes this.
  24. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    OK I got you oh and by the way I tested my Saitek X45 and yeah I got the throttle to work but for simple turning left and right and pitching up and down with the joystick part I couldn't get it to work as I don't see a pitch or yaw control in the integration only horizontal 1 and 2 and vertical 1 and 2 and they had a habit of just having a continual turn to the left or spin on its axis depending on what combination of commands I used, the rudder works as well though more like an aircraft rather than a typical Space Sim roll
     
  25. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    OK fine as I said the joystick controls in Unity are limited and don't cover every H.O.T.A.S system on the market especially the higher end stuff. I can well imagine players with Elite Dangerous trading up to higher end H.O.T.A.S 's as I am one of them (though I haven't been on the forums ) I would say players have always wanted the higher end stuff since the Wing Commander days I personally have all the Thrustmaster Afterburner USB models, the TFlightX HOTAS, Thrustmaster Attack Throttle, Saitek X36 both USB and Serial HOTAS's and Saitek X45 with Scythe 2 footpedals( I am not going to go out there and by a set of pedals for £99.00 possibly when I am rich but not before then) So I understand what you mean that Rewired is a solution for you
     
    Last edited: Dec 1, 2018
  26. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    6,049
    Hi, sorry for the delay, I didn't notice this comment before.

    Vertical1 is for pitch (up/down), Horizontal1 is for yaw (left/right) and Horizontal2 is for roll.

    The reason why I named it like this is because these axes are also used for looking around with the camera etc, so it was necessary to put more generic names here.

    If you look at the HOTAS template I prepared:
    • The stick X is linked to Horizontal2 (roll)
    • The stick Y is linked to Vertical1 (pitch)
    • The stick rotate is linked to Horizontal1 (yaw)
    Untitled.png

    Can you check that this is how your Rewired map is set up? If there's still a problem, can you debug the value of the Horizontal1, Vertical1, and Horizontal2 axes when you move your joystick?
     
  27. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449

    OK Thanks I will try it again
     
  28. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    No its just spinning on its X axis OK How do I debug?
     
  29. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    6,049
    First, is your rewired map set up as shown in the image I attached in my last comment?

    Add this line to the Update() method of RewiredPlayerSpaceFighterControl:

    Code (CSharp):
    1. Debug.Log(rewiredPlayer.GetAxis("Vertical1") + "  " + rewiredPlayer.GetAxis("Horizontal1") + "  " + rewiredPlayer.GetAxis("Horizontal2"));
    Take a note of what values are shown in the Console tab when your stick is:
    • Left;
    • Right;
    • Forward;
    • Back;
     
  30. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    (1) What windows operating system are you using?
    (2) What version of Unity are you using?
    (3) Is the rudder currently in the middle or it is pushed all the way left or right on Saitek X-45?
    (4) Did you calibrate your Saitek X-45 on windows?

    I did not see this posted earlier in this thread.
     
    Last edited: Dec 2, 2018
    Billy4184 likes this.
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,637
    Billy4184 likes this.
  32. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    6,049
  33. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    Yes it is I did exactly as how you had it in the last comment
     
  34. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    Unity 2018.2.8f1
    Windows 7 Professional
    The Rudder is fine its the X and Y Steering that there is a problem with steering the X45 doesn't have twist rudder on the stick
     
  35. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    Just tried it with my TFlight HOTAS X and it worked fine but use the H.O.T.A.S template not the TFlight H.O.T.A.S template as well it doesn't pitch up and down but with the ordinary H.OT.A.S template it works perfectly fine
     
  36. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    The HOTAS template maps the rudder to the twist stick name so it is not a problem. The Rewired template does similar things for other HOTAS elements from other vendors and it works without a problem.

    If you try the Saitek X-45 "template" directly instead of using the HOTAS template do you get the same results?

    Are you using the Raw Input (default) or Direct Input with the Rewired Input Manager? This is under Platform settings / Windows / Primary Input Source. This is the drop down in that section.
     
    Last edited: Dec 3, 2018
  37. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    Haven't tried it with just the pure 'Saitek X45 '' template OK I will try it like that again
     
  38. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    No it still spins on its X axis it could be the stick but it works OK in games so not sure what it is could be my mapping how do you map the yaw and pitch controls for the Saitek map then please.?
     
  39. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    I just tried my Saitek X45.

    Everything works, more or less. The pitch is inverted (pulling up pushes the ship down), but the bank and rudder and primary/secondary fire work as expected.

    Clicking the Invert Axis checkbox in the HOTAS template mapping for "Vertical1" fixed it. I assume that would fix it for any HOTAS devices. On a side note, I'd think "Pitch" would be a better Action name?

    The throttle also works, though at the max it only goes up to half throttle in the game.

    Side note: there's a cool feature in the Input Manager under Tools that exports Actions (and some other stuff) as constant int values in a .cs file. It's a nice way to reference actions, rather than using strings.
     
  40. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    6,049
    Thanks for testing! Great to hear it works, and I'll take a look at inverting the pitch. Is there a reason why the throttle axis would only go up to 0.5?

    The reason why it's named Vertical1/Horizontal1/Vertical2/Horizontal2 is because the steering controls, strafe controls, and camera controls all use the same controls on the gamepad depending on modifier buttons. Creating a number of different maps may be a better choice, although it seemed a bit redundant at the time.
     
  41. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    OK I will try this
     
  42. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    OK For the Saitek X45 What is the correct combination because I still get spinning on the X axis Throttle and rudder are fine but steering and pitch are not working (for me) which can't understand because the Thrustmaster TFlight HOTAS X works fine, absolutely no problems there
     
  43. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    6,049
    I have created an integration for the gamepad and HOTAS templates only, so since I don't have that joystick I can't really deal with a problem that is specific to that joystick.

    Did you try the Debug Information feature that guavaman kindly pointed out to find out what is going on?
     
  44. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Does your Saitek X-45 behave as expected when you use the Windows Control panel? When you are calibrating the Saitek X-45 does everything work as expected?

    If you have a different USB port you might try that instead. Unplug from the Saitek X-45 current usb port and then plug in to a different USB port. Install any device drivers if required if Windows does not find any drivers.
     
    Billy4184 likes this.
  45. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    6,049
    @Vampyr_Engel by the way, when you say your joystick works in other games, does it work with other projects containing Rewired, specifically when using the HOTAS template?
     
  46. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Do you have any other HOTAS devices to test?
     
  47. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,637
    You need to go through and diagnose what the problem is and understand why it's happening to fix it.

    Debug Information is the most powerful tool for doing this:
    http://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information

    There are 4 things that go into determining value of an Action in Player:
    1. The Controller(s) assigned to the Player.
    2. The Controller Map(s) that binds Controller elements to Actions.
    3. If the Controller is a Joystick, the Calibration Map for that Joystick.
    4. The Input Behavior assigned to the Action.

    All of these affect the final output of Actions, so you're going to have to check every one of them.

    I don't really understand what you mean by "spinning on the X axis." If Actions for "Steering" and "Pitch" are not working, then you must check that they are actually bound to working Joystick elements in the Controller Map.

    Start at the highest level first:
    Controller Maps and bindings.

    Debug Information -> Players -> Player # -> Controller Maps -> The Joystick Name -> The Controller Map.

    1. Is there a Controller Map loaded?
    2. Is the Controller Map enabled?
    3. Are the bindings you expect to see present?
    See Players -> Player # -> Controller Maps -> The Joystick Name -> The Controller Map -> Button Maps
    Players -> Player # -> Controller Maps -> The Joystick Name -> The Controller Map -> Axis Maps
    Verify the bindings are correct. For example, Stick X (Horizontal)

    If the Controller Map is loaded and the bindings are what you expect, check that the Joystick is actually returning some value for those elements.

    Debug Information -> Controllers -> Joystick -> The Joystick -> Axes
    Debug Information -> Controllers -> Joystick -> The Joystick -> Buttons

    With the fields open, click back into the game window and start using the joystick. Do the values in the inspector change for those axes? Do the values look to be the correct values? -1 to +1 for an axis. Are any axes returning non-zero value when you're not expecting them to?

    If the values returned are odd, for example only returning a range from 0.5 to 1, move on to check the Calibration Map:
    Debug Information -> Controllers -> Joysticks -> The Joystick -> Calibration Map -> Axis Calibrations (one for each axis)
    Open them and check the settings:
    Calibrated Max, Calibrated Min, Calibrated Zero, Dead Zone, Invert, Sensitivity Type, Sensitivity

    You can also check the Input Behavior settings for the Actions in question, but that's probably not the issue here based on your description.

    You should be able to determine where the problem is coming from (hardware, mapping, calibration).
     
    Last edited: Dec 4, 2018
  48. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    6,049
    Thanks for taking the time to write that out. I'm still getting to know Rewired but I can see just how comprehensive its feature set is.
     
    guavaman likes this.
  49. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    Well I have the full CH setup (throttle, stick, rudders) - on your recommendation, haha.

    But that's a more complicated case, since the software lets you go crazy with remapping. I'm not 100% sure what the "default" state of that setup even is. My Unity machine doesn't have the CH software, which maybe is good. Not sure if you can just plug that stuff in generically without the CH software and expect it to work right or what. I guess I can try it and see what happens.
     
  50. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    I don't know, the same throttle works properly on my space game. Could be some kind of scaling in how you're interpreting the input?

    The Action names are more of a style issue I suppose. In my space game, I went ahead and named actions based on what they mean in the context of the game. May not ultimately matter, but in my case I allow full input remapping, so it makes things super flexible (for better or worse).
     
    Billy4184 likes this.