- Home /
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");
Answer by Ken_y1 · May 04, 2018 at 02:06 AM
You can try to change the Response Speed on Axis Touch Button Script which you have attached to you UI buttons.
Answer by sorcerboo · Oct 25, 2020 at 01:40 AM
Add this text: Project settings > Player > Other settings: Scripting Define Symbols: "CROSS_PLATFORM_INPUT;MOBILE_INPUT"
Answer by LesleyWit · Jan 07, 2018 at 04:32 AM
Bump, i've got the same issues and am looking for an answer.
Answer by DevilZ1976 · Feb 08, 2019 at 08:23 AM
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
thank u so much it really worked,,, what about the jump button I have the same issue?
Answer by Wolverine-X-man · May 24, 2020 at 07:02 PM
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...
Your answer
![](https://koobas.hobune.stream/wayback/20220612133928im_/https://answers.unity.com/themes/thub/images/avi.jpg)