The camera moves after the cursor and edge of the map

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

Hello, dear Godot engine experts! I had this problem: I made a tile map (the map size is from -512 to 512 tiles and from -255 to 224 tiles, the tile size is 32 pixels). I wrote a script for the camera to move, approach and move away. But the camera moves only with the “up”, “down”, “left” and “right” buttons! Please help me write a script so that the camera moves with the mouse cursor. And also round off the map as “Earth” so that when the edge is reached, the camera starts displaying the other edge!!! Thanks !TileMap

Camera script

Camera script 2

:bust_in_silhouette: Reply From: zhyrin

Your camera moves with button presses, that means you handle input somewhere.
If you want to use mouse motion, you should also update the camera based on on InputEventMouseMotion, which you can do in _input() or _unhandled_input().

To make the map wrap around, first write the function that does the teleporting: when you reach one end of the map, it should teleport you to the other end.
Then to make it look like you are wrapping around instead of teleporting, copy a segment from the edge of your tilemap and paste it next to the other edge. You would essentially extend the tilemap in every direction, but you keep the playable area the same size.