CollisionPolygon2D doesn't have a collision signal?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By P0werman1

I have a CollisionPolygon2D with a defined shape, but in the “node” area it doesn’t show any signal for collision? It lists:


However, according to what I was reading in the docs and on other forum posts, it should have area_entered for entering an Area2D, and something else I couldn’t find for colliding with another hitbox.

What’s going on? Can someone help me?

:bust_in_silhouette: Reply From: jgodfrey

Generally, the signals you’re referring to will belong to the parent of the collision object (an Area2D for example). A typical scene layout might look like:

   +-- CollisionShape2D
   +-- Sprite

The Area2D requires some sort of collision object child to detect collisions, but the signals you’re referring to are on the Area2D node itself.

I have it in a CharacterBody2D, is input_event(viewport:Node, event:InputEvent, shape_idx:int) what I’m looking for? How do I use it?

P0werman1 | 2023-05-10 14:13

Ah, with a CharacterBody2D, you should be moving it via move_and_slide() or move_and_collide().

move_and_collid() returns a KinematicCollision2D directly. And, with move_and_slide() you can process collisions via get_slide_collision_count() and get_slide_collision().

I’d recommend you read this docs page thoroughly, as it provides details on collision detection when using a CharacterBody2D.

jgodfrey | 2023-05-10 16:55

Thank you! I’d been moving the Node2D that the CharacterBody2D was inside of…
Should I not have it inside of a Node2D?

P0werman1 | 2023-05-10 17:02

That sounds like an odd setup. Unless you have a sound reason for doing so (I’d be curious what this is), I probably wouldn’t do that…

jgodfrey | 2023-05-10 17:38

I didn’t, so I removed it. I just had the CharacterBody2D inside of a Node2D. No real reason lol.

P0werman1 | 2023-05-10 17:42