I cant interact with npc

Godot Version

Godot 4

Question

Hello, I am trying to make a dialogue system with Nathan Hoad’s dialogue plugin. I made my npc a characterbody with a colisionshape, sprite and an area 2d . My problem is that I have set the mask of the npc’s character body at 5 layer at 1 , the area2d mask on 5 andsame for the player
And the characters just phase true and cant interact or the text laber I put above the npc doesnt show up when you enter his body and I dont understand what I did wrong

func _on_chat_detection_area_body_entered(body: Node2D) -> void:

	text.visible = true

text.visible = true

This is the code for the npc

extends CharacterBody2D
@export var dialogue_resource:DialogueResource
@export var dialogue_start: String = "start"

@onready var text = $Label

var jucator
var is_chatting = false
var player_in_chat_zone = false

func _on_chat_detection_area_body_entered(body: Node2D) -> void:

	text.visible = true
	if body.has_method("jucator"):
		jucator = body
		jucator._player_in_chat_zone = true


func _on_chat_detection_area_body_exited(body: Node2D) -> void:
	text.visible = false
	if body.has_method("jucator"):
		player_in_chat_zone = false
		
func _process(delta: float) -> void:
	if Input.is_action_just_pressed("talk") and player_in_chat_zone == true :
		DialogueManager.show_example_dialogue_balloon(dialogue_resource, dialogue_start)

You need to set the NPC’s area’s collision mask to 5, but the Player’s area’s collision layer to 5 (or the other way around if I misunderstood your setup correctly).

Basically collision mask is set up on the area that detects something, while collision layer is set up on the area that is being detected.

**It doesnt work.
And for the character mask and layer what do I need to do?

Like before I had and area 2d for the npc instead of a character body and it was working but the dialogue wasnt working properly so I tried to change it

Did you connect the signals properly?

yes, I contected the body_entered signal to the caracter body of the npc and same for the body_exited . For the player I dont have any signals

It was the mask as you said at first, ty a lot

1 Like