Aiming the camera with both the mouse and Joystick simultaneously in Unity using legacy InputManager
Many Unity games just support mouse and keyboard (WASD) for first person control. But if you are using the legacy input manager (most if not all the free first person controllers do) it's easy to make the gamepad right joystick work for to aim the camera and still support mouse look too!
The secret is the name of an axis (such as mouse y) can refer to multiple input devices. Unity will respond to whichever is being moved. So you just need to add a definition in the input manager for Mouse Y & X that also refers to the joystick. You can use the GUI for this (Edit > Project Settings > Input Manager), or you can edit the file directly, which is what I describe here.
Right click on The Assets folder in the Project tab and select Show in explorer. From here open the ProjectSettings folder and then edit InputManager.asset using your favorite text editor.
Go to the bottom of the file and add a new line just above the last line, which should be
m_UsePhysicalKeys: 0
then paste this code into that empty line:
- serializedVersion: 3 m_Name: Mouse X descriptiveName: R_Joy_x descriptiveNegativeName: negativeButton: positiveButton: altNegativeButton: altPositiveButton: gravity: 0 dead: 0.1 sensitivity: 1 snap: 0 invert: 0 type: 2 axis: 3 joyNum: 0 - serializedVersion: 3 m_Name: Mouse Y descriptiveName: R_Joy_y descriptiveNegativeName: negativeButton: positiveButton: altNegativeButton: altPositiveButton: gravity: 0 dead: 0.1 sensitivity: 1 snap: 0 invert: 0 type: 2 axis: 4 joyNum: 0
Note the spaces matter. the - has to be on the same column as the m in m_UsePhysicalKeys
Tested and working in Unity 2021.2.33f1 (latest LTS version as of 2023).
Comments