Capturing a Crosshair Within a Game Window

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Shahit_Ahn

Hello there!

I’m trying to make a 2D top-down game, and came across a problem I can’t quite solve.

How to confine a 2D sprite (i.e. sprite cursor, crosshair, etc.) that’s affected a mouse sensitivity to a game window or a viewport so it would leave screen borders?

I’ve tried it with both MOUSE_MODE_CAPTURED and MOUSE_MODE_CONFINED, tried to to clamp the position of a sprite, but ultimately couldn’t find anything that would solve this problem.

I don’t understand the problem clearly

look “Clamp”
Coding the player — Godot Engine (stable) documentation in English

ramazan | 2022-03-24 08:35