Can I control a camera using the Joystick hat to look around in a starship or aircraft cockpit?

Yes How would I be able to do that using the Joystick commands? I know it might become obsolete because of Virtual Reality Headsets and IR tracking but for those causl gamers how can I set this up in Unity?

You can set up the joystick hat via Edit → Project Settings → Input. Create two new axes (one for vertical and one for horizontal), and then figure out which joy axis (via the dropdown next to “Axis”) is the right one. Then you can use Input.GetAxis to get that input in game.

TBCH this is a terrible solution, as your players will have different joysticks that will map their hat to different axes, in addition to being a major pain to set up in the first place. Unity’s current joystick input system is awful, and it’s been in the works for a while to overhaul the Input system entirely, and it looks like you can grab an experimental preview for that if you’d rather play with experimental software than use lousy, but stable software.

Well yeah I know that thier joystick controls are pretty weak to say the least especailly when compared to Dark Basic even though your more programming the joystick axises and hats to different fucntions sorry but its a lot better once you know how I just hope that the VR controls will be better as I see that taking over from looking around the cockpit with a joystick hat view. And I am looking to control the camera with a Jaystick HAT /POV view and not a main axis like the X or Y or RZ or U or Z axises

I don’t mind even coding it to be honest as I found it a bit difficult to connect the camwera to the joystick first time I tried it though got my hovertant to work with my Saitek X45, and my T.Flight H.O.T.A.S X

That is precisely why I use Rewired. It handles all types of flight controllers and you have each joystick element named. The Saitek X-45 and T Flight H.OT.A.S X are on the list. You can always try the free trial version of Rewired to see how well works in controlling POV HATs.

@Steve-Tack uses Rewired with his Saitek X-45 also. I have used Rewired with my T.Flight H.OT.A.S X also. It is the only way to work with POV HATs in my opinion.

https://www.assetstore.unity3d.com/en/#!/content/21676

Rewired has the most popular flight controllers on the list too like Saitek X-55 Rhino, ThrustMaster Warthog, CH FighterStick and much more.

See the huge list of supported controllers and scroll down to the middle to see the long list of flight controllers.

http://guavaman.com/projects/rewired/docs/SupportedControllers.html

Yeah, if you want to support flight sticks, buy Rewired. There isn’t another reasonable option that I’m aware of. Rewired comes with “templates” for gamepads and HOTAS (flight sticks and throttles). So if you want to map an action to pitch or hat switch 1, you can map that to the generic HOTAS template, and Rewired will translate that to a large number of devices. If you go ahead and map to the gamepad template too, you get support for like 90 gamepads automatically too, with little effort. As in, it just works for your players with no mapping required on their end.

Plus if you put the Rewired remapping UI in your game, you can essentially support just about any input device, no matter how obscure it is.

Thank you guys I will have a look at Rewired, if it can do the Joystick POV great of course the camera view will be controlled via smartphones and the Occulus rift but for those who don’t have it and can control the camera with a Joystick Hat or POV well that would be great and professional

(1) Rewired has a very active forum thread and great developer support.

https://forum.unity3d.com/threads/rewired-advanced-input-for-unity.270693

(2) Rewired HOTAS templates

In the Rewired HOTAS templates the HAT1 should be the POV HAT across all of the more popular joysticks.

In my forum message post I talk about the Rewired HOTAS template subset that appears to work fine from the $20 ThrustMaster USB joystick all the way up to the high end $500 ThrustMaster Warthog. So HAT1 on the template should cover your POV for most joysticks.

https://forum.unity3d.com/threads/rewired-advanced-input-for-unity.270693/page-56#post-2953481

(3) Rewired Control Mapper

This is the drop in UI (that Steve Tack was talking about) that will allow your users to remap the various controllers too.

More info can be found here:

http://guavaman.com/projects/rewired/docs/ControlMapper.html

(4) This is where you can get the trial version of Rewired.

NOTE: The only limitation is a 2-minute timeout on during runtime. Each time you start the game the timer is reset so you can evaluate as long as you like.

http://guavaman.com/projects/rewired/trial.html

This was actually a good test case so I created an example:

Unity 5.5.0f3 (Windows 64-bit)
Rewired 1.0.0.112

So I used the POV cameras defined in X-plane 10 for my test case since you said cockpit. So I created a new scene with the Rewired Input Manager. Added a cube and then attached the following script (at the bottom of this message) to the cube. For mappings I mapped keyboard, Racing Wheel template, HOTAS template and gamepad templates just for completeness.

2957041--219401--scene_POV_example.JPG

Rewired is all about actions so the POV camera names are names I picked for my actions. So you only have to worry creating your actions and then mapping joysticks, gamepads, wheels, keyboard and mouse to your actions.

First we define the player and what maps the player uses:
NOTE: In this case we will be assigning the default joystick and default keyboard maps to the player.

2957041--219396--Rewired_player_def_POV_example.JPG

Define Actions used by the player
NOTE: These are based on the X-plane POV camera names since they were a good example for a cockpit POV example.

2957041--219397--scene_actions_POV_example.JPG

Map the HOTAS templates. I also mapped the Racing Wheel and Dual Analog Gamepad templates for completeness.

2957041--219399--scene_joystick_maps_POV_example.JPG

Map the keyboard

2957041--219400--scene_keyboard_maps_POV_example.JPG

Then we are all done and the best part is it does not matter if I press POV HAT on my joystick, button on my gamepad, button on my racing wheel, or a key on the keyboard. It all handled automatically for me in the code. So your code is very clean.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Rewired;

public class POV_test : MonoBehaviour {

    public int RewiredPlayerId = 0; // The Rewired player id of this character
    private Rewired.Player Rewiredplayer; // The Rewired Player


    void Awake()   // added 1/15/2017
    {
        Rewiredplayer = ReInput.players.GetPlayer(RewiredPlayerId); // added 1/15/2017
    }

    // Use this for initialization
    void Start () {
 
    }

    // Update is called once per frame
    void Update () {
 
        if ( Rewiredplayer.GetButton("Moving_Spot") )
        {
            Debug.Log("POV: Moving Spot");
        }

        if (Rewiredplayer.GetButton("Hold_at_Location"))
        {
            Debug.Log("POV: Hold at Location");
        }

        if (Rewiredplayer.GetButton("On_the_Runway"))
        {
            Debug.Log("POV: On the Runway");
        }

        if (Rewiredplayer.GetButton("Circling_the_Aircraft"))
        {
            Debug.Log("POV: Circling the Aircraft");
        }

        if (Rewiredplayer.GetButton("Tower_View"))
        {
            Debug.Log("POV: Tower View");
        }

        if (Rewiredplayer.GetButton("Ride_Along"))
        {
            Debug.Log("POV: Ride Along");
        }

        if (Rewiredplayer.GetButton("Track_fired_Weapon"))
        {
            Debug.Log("POV: Track fired Weapon");
        }

        if (Rewiredplayer.GetButton("Chase"))
        {
            Debug.Log("POV: Chase");
        }


        if (Rewiredplayer.GetButton("Exit_POV_Test"))
        {
            Application.Quit();
        }
    }
}

= = = = = = = = = = = =

NOTE: The next message will have a zip file with (the files I used) more information on how I tested this.

Test setup requirements: Unity 5.5.0f3 and Rewired 1.0.0.112

This attached file contains a zip file with the Rewired Input Manager prefab, example scene, and script. So unzip the file and then drag the Rewired Input Manager into your new scene, add a cube, attach the included script to your cube and that is it.

Testing was done using a XBOX-360 gamepad, ThrustMaster T-Flight Hotas X, keyboard, ThrustMaster T300RS racing wheel, and other HOTAS systems.

2957046–219402–Rewired Input Manager_POV_test.zip (11.5 KB)

Thank you very much for your work longroadhwy I look forward to testing all this myself and implementing it in my game . I shall have to buy this utility but this is just what I need Great and thank you once again

No problem at all.

Everything I did also works with the trial version of Rewired too.

Been a fan of Rewired since the beta release. Definitely the most important third party asset I own. It also has very good documentation too. Very helpful FAQs and just well organized documentation.
http://guavaman.com/projects/rewired/docs

The nice part about the native input that Rewired provides is that input works the same across Windows/MAC/Linux. This is a huge benefit especially for those who love Flight controllers and want to have releases on multiple platforms.

With regards to VR both ThrustMaster and Logitech’s Saitek unit sell a large number of HOTAS systems for use with VR also. The Elite Dangerous space game is very popular with both HOTAS devices and VR. It is a very good example of both HOTAS and VR working together. But also Elite Dangerous works just fine with joysticks and HOTAS systems without VR.

Have you been able to integrate Rewired with your game yet? Just wondering how it was going.

Rewired is on sale if you have not purchased yet. (Unity’s wish list sale).

[QNo nmot yet as I am testing the demo and having a a few problems connecting ut , must say though it has akk the axises and buttons, As my game is set on actual cyberplanets I hope I can get this to work for tanks hovr and hovercraft Tanks and Air/Space fighter craft. I9 have to wait till I can get some cash again to get the full version , hopefully I will be getting that soon …

Glad you are working with the trial version.

If you have any questions you should post them in the main Rewired forum thread so more people can see your question and of course the author of Rewired can provide good guidance on what to do.

Rewired Forum thread:
https://forum.unity3d.com/threads/rewired-advanced-input-for-unity.270693/

OK I will Thank you very much for your help

Yeah the problems I am having is I don’yt know which axies in Unity and Rewird are for Joy U or Z for ward and backward movement and what would be for Rudder/Straffing movement which is usually Joystick Axis RZ as well as getting the Joysticjk POV hat controls

I answered this question in the Rewired forum thread.

https://forum.unity3d.com/threads/rewired-advanced-input-for-unity.270693/page-58#post-2982149