Request for assistance debugging collisionshape2d

Godot Version

4.3

Question

Would appreciate if someone could look at my simplified code here to advise on what I’m doing wrong. Spent many hours and cannot figure out what I’m doing wrong.

NOTE: Arrow keys are used to move the ship.

I have 2 collisionshape2d in my Asteroid shooter game. The top level shape for the actual asteroid collides properly.

However my 2nd shape is intended to represent the future position area of the asteroid over the next several seconds. Oddly I can’t detect a collision against this 2nd shape which is nested one level down.

Here’s what the “nest” collisionshape2d scene looks like.

image

Are the collisionmask and layer setup correctly?

@herrspaten Yes, both asteroid collision shapes are setup identically as below.

And the ship is on layer 2.

Are you sure that you connected the signals of the asteroidfuturecollisionarea?
I cant find the connections in your provided github-project

1 Like

I am listening to both of these signales in the asteroidfuturecollisionarea. For some reason, they are not being activated:

Yes because they are not connected. Having these methods doesnt mean they get called. For this to happen you have to connect the signal either through the inspector or in code:

func _ready() -> void:
    body_entered.connect(_on_body_entered)
    area_entered.connect(_on_area_entered)
1 Like

@herrspaten That was it. Oddly those connections were not required for the top level collisionshape2d (asteroid) but only for the lower level collisionshape2d (asteroidfuturecollisionarea).

I.e. the Asteroid’s _on_body_entered is being called even though it doesn’t contain a body_entered.connect(_on_body_entered).

For the top-level area it was already connected through the inspector, thats why this wasnt necessary

@herrspaten Thanks for all your help.

When you say “already connected through the inspector”, is that an automated feature without a UI selector in the Inspector or is there a selector for connecting signals in the Inspector that i missed?

1 Like

Its next to the Inspector. When you click on a Node:

1 Like

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