When you have a selected unit and move the cursor over a target unit, nothing happens. The target is invalid in the project’s current state.
In those cases, offer the player to move to a cell in front of the target closest to the moving unit, as shown in the picture below.
Here’s a breakdown of how the feature should work.
Steps:
The code should also take into account if another unit occupies the cells surrounding a target unit, as illustrated below.
Hints:
Vector2
class provides the function(s) you need to compare them to the selected unit’s position.GameBoard.gd
, as the script triggers drawing when the cursor moves.