How to make the player characters movement restricted to a circle that spawns with them in the center every round.

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

I’m making an RTS but I would like the player character to be restricted to a circle in which they can move around freely. I need the answer to be compatible with multiplayer and move_and_slide(). Thank you in advance. I am using a kinematicBody2D.

I need the answer to be compatible with multiplayer […]

What does that even mean? Local or online multiplayer? Can the circle of another player and yours overlap? What is supposed to happen then?

I need the answer to be compatible with […] move_and_slide

Again: what do you mean? Why should it not be compatible with move_and_slide? In the end all you have to do it calculate the border coordinates of a circle around the center and check before each move of the player, if that move would move them outside of these coordinates - in which case you wouldn’t perform the movement.

njamster | 2020-07-16 17:55

:bust_in_silhouette: Reply From: Ras0922$$

Try this out maybe it will help
https://forum.godotengine.org/46417/how-to-prevent-player-from-moving-outside-the-shape-or-area