I'm trying to make a prototype for a turn-based dungeon crawler. I say "turn-based" because I want the player to move tile by tile, without necessarily using a _process function.

I've looked at the 2D Role Playing Game Demo. I notice it uses the tilemap for every game entity; walls, player, NPCs, and items. Before moving to the next tile (of the given direction), the game checks whether it contains a wall tile or another object, using the TileMap.get_cellv() function.

So far so good.

But what if I wanted to have a Node2D (or some subclass of that) for NPCs/enemies and items? I know the target position, but I can't seem to find a way of checking whether that position contains a node (while I can check a TileMap for a specific tile).

And I'm guessing many will suggest I use _process and Area2Ds and signals. But I'd rather not, since it's a game where everything moves step by step and I want to keep it to the bare essentials.

Note: Area2Ds only seem to work asynchronously (aka with signalling), while get_overlapping_areas() doesn't work properly either.

You could check whether the Node2D's position is within the tile's rectangle. The Rect2 method has_point() would be helpful there.

    DaveTheCoder I have never used the Rect2. It doesn't even seem to be a subclass of Node or Reference. How do I use it?

    Rect2 is a simple class like Array or Vector2. Just use it as a variable type.

    Here's some random code that uses Rect2:

    var top_left: Vector2 = Vector2(1.0, 2.0)
    var size: Vector2 = Vector2(3.0, 4.0)
    var r: Rect2 = Rect2(top_left, size)
    r.position = Vector2(5.0, 6.0)
    r.size = Vector2(7.0, 8.0)
    var b: bool = r.has_point(Vector2(9.0, 10.0))
    
    var viewport_rect: Rect2 = get_viewport_rect()
    var rect: Rect2 = get_rect()
    if viewport_rect.encloses(rect):
        # do something
    if rect.position.x < viewport_rect.position.x:
        rect_position.x = viewport_rect.position.x
    13 days later