Position UI to mouse position (Make Tooltip panel follow cursor)

后端 未结 2 590
感动是毒
感动是毒 2021-01-20 15:39

I made a tooltip panel follow the cursor with

void Update () {
    this.transform.position = Input.mousePosition;  
}

in the Update functio

2条回答
  •  甜味超标
    2021-01-20 15:55

    This is a known issue with unity.

    While binding mouse position to any gameObject's position, we face lag. This lag is introduced by unity input module's mouse position recording. Reference1, Reference2.

    Work Around : You can make your own cursor in game and bind it to mouse position(as you're binding the UI panel). The custom cursor object in game will have the same position as the the panel because both of these objects will derive their position from same source. And you'll get a lag free panel. :)

    Remember to hide the default cursor.

提交回复
热议问题