Mobile Touchpad using New Input System

Hi there,

I am designing FPS Controls for my new mobile game. I have a GameObject named Player having CharacterController component. I have attached the main-camera as a child to this gameobject. I have seen the documentation and followed some tutorials for implementing touchscreen controls using New Input System. I have successfully implemented the Axes for movement and some buttons for Firing, Reloading etc.

All I want to do now is implement the touchpad. This is a area in the UI, on which the player drags, the camera is rotated accordingly (Like we do with mouse in popular PC games such as Call Of Duty games).

How can I implement this touchpad? I will be grateful for the help.

Thanks

Where the inputs come from should not matter, old system or new system.

If you want an example of a 2D touchscreen virtual analog joystick, there were some in the Unity Standard Assets but they always had irritating things I did not like, so I wrote my own and called it VAButton

It uses the old input system but you could easily change it to the new input system. See below.

Look in my ProximityButtons project for the DemoTwinStickShooter scene and scripts, which show how to make these things. The main creation is here, lines 64 onwards:

The reading of input from those two joysticks is in the UpdateGatherTouchInput(); method, and after that, only the temporary input variables are used.

This is the actual VAButton class:

but 100% of the touch it uses is collected in the MicroTouch.cs class here:

You should be able to get it working by just commenting out any stray old input system code (such as OverlayStandardInputAxes () method) and changing the very few lines of code in MicroTouch.cs that read touch, probably starting at line 80 above for the most part.

1 Like

Thanks for the help. I worked. I updated the code to work with New Input System. Thanks Once again.