I want click the screen and move my button to the position on UI Screen, but i found the mouse’s position.x * window.devicePixelRatio is not equal to the position.x on UI.
Hi @Tidus,
There is an ElementDragHelper() class which you can use, check this forum post by @LeXXik, it contains an example project:
Thanks,but i don’t want to drag my element, i need move it to where i click on the screen.
Hey @Tidus, you can check this tutorial to understand how to get the x and y positions of the mouse, and then move the entity there when you detect a click event. If you are unsure on how to detect a click event, the same tutorial goes over how to detect a click.
1 Like
Here is an example project using an element container to easily get mouse input in a 2D screen (there are many ways to do this):
2 Likes