Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Unity Cross Platform Input Not Working?

Discussion in 'Editor & General Support' started by Smotteh, May 17, 2018.

  1. Smotteh

    Smotteh

    Joined:
    May 28, 2015
    Posts:
    22
    Code (CSharp):
    1.   var x = Input.GetAxis("Horizontal") * Time.deltaTime * 150.0f;
    2.         var z = Input.GetAxis("Vertical") * Time.deltaTime * 3.0f;
    3.  
    4.         transform.Rotate(0, x, 0);
    5.         transform.Translate(0, 0, z);
    6.  
    I imported the Unity Cross-platform Input package
    Added the Single Joystick control to my scene with the Input axes "Horizontal" and "Vertical"

    Enabled Mobile Input

    Works perfectly with WASD but the Joystick isn't moving the player

    Am I missing something?
     
  2. Smotteh

    Smotteh

    Joined:
    May 28, 2015
    Posts:
    22
    Figured it out, So basically

    if you're using Joysticks you must add

    using UnityStandardAssets.CrossPlatformInput;

    and instead of

    Input.GetAxis

    you must use

    CrossPlatformInputManager.GetAxis
     
  3. sahilushaikh6

    sahilushaikh6

    Joined:
    Dec 4, 2018
    Posts:
    3
    my joystick is not visible