Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Mouse.current.WarpCursorPosition works correctly in Unity, but not in my build.

Discussion in '2D' started by Mokofr, Aug 18, 2021.

  1. Mokofr

    Mokofr

    Joined:
    Jul 23, 2013
    Posts:
    10
    Hey everybody!

    So I am using this code:

    Code (CSharp):
    1. Mouse.current.WarpCursorPosition((Vector2)mainCam.WorldToScreenPoint(constance.transform.position));
    2. InputState.Change(Mouse.current.position, mainCam.WorldToScreenPoint(constance.transform.position));
    to put the cursor immediately on my character when clicking the right mouse button.
    The cursor is usually invisible and this has to happen cause afterwards the player can draw with the brush and the drawing should always start from the character. For the recording I made the cursor visible so you can see what is going on.

    Works perfectly fine in Unity itself, but in the build of my game, the right click makes the cursor jump somewhere above her and then when you move it there, the brush quickly follows there as you can see in the second half of the video.

    What could be happening here, that it behaves differently than in the editor? Unity Version: 2021.1.7f1

    Cheers!

    Link to demonstration: https://drive.google.com/file/d/12tiJlpzlV3o1q8wail-u10x0GoebyXcO/view?usp=sharing