Collision not responding even if its on the same Layer and Mask

Godot Version

Godot 4.6

Question

Hello!

I’m making an enemy for my game, and I’m trying to add some code that runs when the player collides with it, but its not showing up!

extends CharacterBody2D

@onready var chip: CharacterBody2D = $"../Chip"

func _ready() -> void:
	pass # Replace with function body.
func _physics_process(delta: float) -> void:
	if not is_on_floor():
		velocity.y = 7000

func _on_area_2d_area_entered(area: Area2D) -> void:
	#This line is broken for some reason. The area2d isnt firing.
	print("i exist")

Enemy Layer and mask:

Player layer and mask:

Why is this happening?

How about your Area2D?
Have you added a shape to it?

Yeah, but i changed the code, and it worked, but i have no idea why!

extends CharacterBody2D

@onready var chip: CharacterBody2D = $"../Chip"
@onready var area_2d: Area2D = $Area2D

func _ready() -> void:
	pass # Replace with function body.
func _physics_process(delta: float) -> void:
	if not is_on_floor():
		velocity.y = 7000
func _on_area_2d_body_entered(body: Node2D) -> void:
	print("hi")


what is the difference between ‘area entered’ and ‘body entered‘?

Ohh man,I even didn’t noticed lol.
Area_Entered is for area2ds soo it will only detect area2d and Body_Entered is for physics bodies only.

1 Like

oh ok thx

@nerdcodestudios I suggest to refer to the Godot Docs whenever you have a question like that. More often than not you will easily find your answer there.
Area2D::area_entered
Area2D::body_entered

1 Like

ok thanks