I want to check if the player is near a door.

In practice, this means that I want to check if the Area2D of the player node overlaps a door node (an Area2D with an attached door.gd script). This is working in Godot 3:


# ...

var door_type = preload("res://objects/door.gd")

# ...

for area in $Area2D.get_overlapping_areas():
    if area is door_type:
        # ...


extends Area2D

# ...

However, in Godot 4 (v4.1.2) I have the following error:

"door_type" is a variable but does not contain a type.

I tried an Internet search for this error, but I did not find any result.

How can I achieve this behavior in Godot 4?


1 Answer 1


Preload the script into a constant:

const door_type = preload("res://objects/door.gd")

Then is should work.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .