Making an area 2d usable once

Godot Version



so we have an area2d that by entering it a dialogue will happen, nice and easy. the problem is that if the player leaves and enter it again, the dialogue happens again. can the area 2d be disabled with _on_area_2d_body_exited(body)? if so, whats the code ?

“_on_area2d_body_exited” is this a method? because if so I couldn’t find any

its the signal that the player leaves the area2d.

You can simply attach a script to your Area2D node and introduce a bool property to keep the entered state. Something like this:

extends Area2D

var player_entered = false

func _on_area_2d_body_entered(body):
    if body is Player and not player_entered:
        // show the dialogue
        player_entered = true

thank you

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.