Place object on the mouse position based on the screen?

How do I move a projectile to a SCREEN position

Basically i need to find a way to calculate the position of a OBJECT that is
located at LAYER1 to be placed at the SAME POSITION OF THE MOUSE IN THE SCREEN and NOT IN THE SAME COORDINATES

What is the expected result

The Pointer object should be placed at the exact location of my Mouse

What is the actual result

My Pointer object doesn’t seem to move accordingly with the Mouse, most likely because the calculations does not include changes on the camera position.

problem1

(Obs: i have a few camera changes for Smooth camera movement (using lerp) and Zoom-out based on Player linear velocity)

If you are positioning Pointer using cursorX() and cursorY() functions, then use ‘cursorX(“LAYER1” 0)’ and ‘cursorY(“LAYER1” 0)’ instead. It’ll use the mouse position for layer1, which will be different to the mouse position on the base layer if you don’t have the same zoom factor on both those layers.

2 Likes