Grid-based movement using AStar3D and Gridmap

Godot Version



I’m working on a RPG that has cell-based movement using the tools described by the title. I got player movement to work as I wanted (for the most part), but then I started coding enemy interactions and things started to get trickier. First, I disabled the cells from AStar3d with set_point_disabled() so that the player won’t try to occupy or even pass by the same cell as an enemy, and it also works.

But now I am trying to code player attacking enemy, and my first idea was: check to see if cell is occupied by an enemy (I have a method that sets the cell it is occupying as “Type: Enemy” stored in a nested dictionary along with the point position and its AStar ID) then transition to state: PlayerChasing. It then moves to the enemy location within attacking range and transitions into state PlayerAttacking.

This would be easy to code, since I only have to check the difference between the index of the array that AStar has given and the size of the array itself to be equal to the attacking range. But since the cell is disabled, when I click on the enemy nothing happens. I thought about enabling the point again once it detects a click but it would most likely cause issues if I decide to make it multiplayer in the future. Any suggestions on how to implement this in a scalable, intelligent way?