How can i interact with the objects to spawn a dialog (like a wooden sign)

Godot Version

Godot 4.2


How can the CharacterBody interact with objects that are on the backround to spawn a dialog?

I don’t have problems with the dialog manage sistem but:

  • I have tried to make an instantiated scene with the object but when the CharacterBody
    enters the area2D, if I use func _action_is_just_pressed (for example the E key), it has to be pressed at the exact frame (which is not good).

  • If I use _action_is_pressed it only works if it was pressed before entering the area2D.

  • I don’t know how to already be on the area when Input “E” is_just_pressed and spawn the

The script that I have already tried is:

func _on_area2D_entered… :
if Input.is_action_pressed/is_action_just_pressed (“Interact”):
DialogueManager.show_example_dialogue_balloon(load(“res://Dialogues/Interacting.dialogue”), “start”)

you can just spawn or enable/disable the collision of area2d from character 2d to detect a body entered like example the sign. so when the pressed “E” it either spawn an area2d with collision near the player or enabled then disabled the player area2d collision

I put on the scene script on_area2D_body_entered to show the dialogue and here, in func _physics_process(delta): PROCESS_MODE_INHERIT if input just pressed

Problem 2

Then in func _ready: PROCESS_MODE_DISABLED but still isn’t working. I don’t know what I’m doing wrong

this is not how you disabled and enabled the collision

use collision_node.disabled=true to disable the collision, and collision_node.disabled=false to enable it

I’m sorry but another time I don’t know what’s the problem now
Problem 3

do you have body_entered signal from Interact area connected to this script?

connect the body_entered signal to a function and that’s how you spawn the dialog when the body is a sign either confirm it by group or name.

Thanks for all the help. It was just that I had the CharacterBody masks and layers limitated to mask 1 and layer 1

1 Like

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