CrossPlatformInputManager.GetAxis() always returns 0

Problem:
Just as the title says. It’s the same for both Horizontal and Vertical axes. Input.GetAxis() works just fine.
Interestingly, when I click Mobile Input → Disable then CrossPlatformInputManager.GetAxis() starts working with the WASD keys.

The specific control I’m using is the DualTouchControls prefab. I removed the turn/look controller but kept the MoveTouchPad.

What I’ve done to try and fix it:

  • Deleting everything referencing the CrossPlatform (including objects in scenes of course) and reimporting
  • Verified that there is an EventSystem in the scene
  • Checked to make sure the MobileControlRig is set to target the correct axes in the inspector
  • Set you Unity build settings to a mobile build (specifically Android)
  • I’ve also built the project and put it on my phone (Galaxy S6) with no luck

Most people with this problem that I have seen from Googling were missing EventSystems but I had always had one and I cannot for the life of me figure this out.

I have not modified any code in the CrossPlatformInputManager and the only code I have calling it is assigning the vertical and horizontal axes to variables:

        float turn = CrossPlatformInputManager.GetAxis("Horizontal");
        float acceleration = CrossPlatformInputManager.GetAxis("Vertical");

You can try to change the Response Speed on Axis Touch Button Script which you have attached to you UI buttons.

Add this text:
Project settings > Player > Other settings:
Scripting Define Symbols: “CROSS_PLATFORM_INPUT;MOBILE_INPUT”

Bump, i’ve got the same issues and am looking for an answer.

Hey ya’ll,

I may have found a temporary solution. Try using virtual axis reference because it sets value to it

horizontal = CrossPlatformInputManager.VirtualAxisReference("Horizontal").GetValue;

If it’s still not working try using .GetValueRaw instead of GetValue and set higher response speed.

Hope it helps,

Stay healthy

float horizontalThrow = CrossPlatformInputManager.GetAxis(“Horizontal”);
this is also working code in the situation in unity 2020.1 (Beta) version

go to Edit → project setting → Editor ->Joysticksource change to Local and run
OR
Restart Your Unity Engine & Visual studio 2019

i am facing the same issue, soo here is my solution…