Lock Object position to a dynamic perimeter

Hi everyone ! I’m actually working on a fake 2D shooter in which the camera follows the player from above. The player object is tracking to a cursor object but I want the cursor to stay at close range of the player because I’m using XBOX controller and for now the cursor can be move anywhere without limits… So I’m asking for a way to limit this cursor from going to far away from the player, like a closed perimeter.

have the controller add and remove value to a x and y property

each frame
cursor.worldPosition = player.worldPosition
cursor.applyMovement((x,y,0),0)

joystick left------------and--------add -1 to X
if X min:-99 max:100/

joystick right----------and---------add 1 to X
if X min:-100 max:100/

Thanks ! Simple and effective :wink: