Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. We are looking for feedback on the experimental Unity Safe Mode which is aiming to help you resolve compilation errors faster during project startup.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Input.GetAxis("Mouse X") and Y-axis equivalent don't work in Remote Desktop

Discussion in 'Editor & General Support' started by GCarty, Dec 14, 2011.

  1. GCarty


    Oct 20, 2011
    I am currently using these functions to move and rotate an object, but they don't work for some reason over a Remote Desktop connection (they always return zero) -- any ideas?
  2. CSharpCoder


    Feb 12, 2013
    Is there a resolution or workaround to this issue? I'm seeing the same problem in Unity 4.0.
  3. jwesolo


    Nov 23, 2012
    I'm also experiencing this...mouse works fine in scene view but not in game view. This is a big deal for me as I do much of my work remotely. I'd love to know if anyone has found a solution.
  4. Arcanor


    Nov 4, 2009
  5. MasterLu


    Nov 23, 2012
    I had the same problem. This workaround works for me.

    Vector3 axis = new Vector3(-(lastAxis.x - Input.mousePosition.x) * 0.1f, -(lastAxis.y - Input.mousePosition.y) * 0.1f, Input.GetAxis("Mouse ScrollWheel"));
    Vector2 lastAxis = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
  6. Annihlator


    Oct 15, 2012
    Thanks for posting the workaround!
    To get a little more into the problem though;
    (I'm assuming we're talking about windows' standard RDP platform)
    When connecting through windows remote desktop most functions are virtualized.
    This makes multiple problems arise where applications normally rely on their hardware counterparts.

    Some of the examples in these limitations are the limitation in use of graphics acceleration, but also other hardware devices aren't accessed/translated directly.

    Normally unity will request Unity's pointer location based on hardware information while the RDP fuels the mouse using this function; while in the virtual environment the link to the hardware that unity's so desperately looking for likely doesn't excist since actually the mouse is remapped from relative movement to resulting location. (Basically unity is at this moment looking for the wrong type of values)

    To illustrate a little different;
    Like as if using a touchscreen, if i tap the screen in a different location the mouse pointer is moved, but unity shouldn't respond. (Because it is simply set to a new location)
    A normal mouse movement would instruct windows to "move that much and that much in that direction" instead of "be here"

    using the workaround MasterLu suggested uses the on-screen-location of the mouse rather then the relative hardware position adjustment for it's input, thus working around it.

    Want to simulate this behaviour? We can use AutoIt.
    Try make a script that places the mouse from one location to the next, and one that MOVES the mouse from one location to the next.
    Unity then should behave like i just described.
  7. Gary Li

    Gary Li

    May 20, 2013
    thanks for posting this! could you please also talk more about how to implement this in your script? Thanks in advance
  8. ProbePLayer


    Oct 19, 2012
    I am necroposting here cause the pandemic has forced remote work more than ever so someone might benefit from this:

    If you are using the Standard Assets FirstPersonController (or RigidbodyFirstPersonController), then all you have to do to get it working over remote is to add the lines of code Master Lu posted in your MouseLook.cs script:

    To be more specific: in that script you will have lines that look something like:
    Code (CSharp):
    1. yRot = CrossPlatformManager("Mouse X") * sensitivity;
    2. xRot = CrossPlatformManager("Mouse Y") * sensitivity;
    all you have to do is this:
    Code (CSharp):
    1. Vector3 axis = new Vector3(-(lastAxis.x - Input.mousePosition.x) * 0.1f, -(lastAxis.y - Input.mousePosition.y) * 0.1f, Input.GetAxis("Mouse ScrollWheel"));
    2. lastAxis = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
    4. yRot = axis.x * sensitivity;
    5. xRot = axis.y * sensitivity;
    and to also declare lastAxis as member variable

    If you are using any other way of handling the input, then I suggest to replace the controller temporarily with a FirstPersonController
  9. armablue


    Nov 27, 2016
    Thanks ProbePLayer I think this is what I need to get my mouse to work on a remote desktop. Just running into one issue with the lastAxis.x and lastAxis.y.

    Vector3 axis = new Vector3(-(lastAxis.x- Input.mousePosition.x) * 0.1f, -(lastAxis.y - Input.mousePosition.y) * 0.1f, Input.GetAxis("Mouse ScrollWheel"));
    lastAxis = new Vector2(Input.mousePosition.x, Input.mousePosition.y);

    float yRot = axis.x * sensitivity;
    float xRot = axis.y * sensitivity;

    I'm getting this error in the console

    Assets\Gaia Dependencies\Standard Assets\Characters\FirstPersonCharacter\Scripts\MouseLook.cs(36,51): error CS1061: 'object' does not contain a definition for 'x' and no accessible extension method 'x' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)

    I am new at this and stuck. Hoping you have the answer!