You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm following the SpaceRocks project but I'm having an issue with detecting Player / Rock collisions. This is almost certainly something I'm doing wrong, I'd just appreciate a pointer as to what that might be.
I've connected a signal to a C# (yes I'm using C#) method on Player.on_body_entered:
publicvoidOnBodyEntered(Nodebody){Debug.WriteLine("collided with something!");if(body.IsInGroup("rocks")&&bodyisRockrock){rock.Explode();Lives--;Explode();}}
The problem is this signal's method is never invoked. I've put a breakpoint at the start of this method and it's just never hit when the player ship and rock meet. I also never see the debug output.
Thanks for the quick response and that's a good thing to check. If I remember correctly, the project in the book doesn't ask you to do anything specific with the collision layers.
Everything (rocks and player) is on collision layer 1, mask 1
Collisions between rocks and bullets (which are Area2D's) work fine (which also suggests the collision shape is correct)
I've downloaded the sample project and compared property-by-property and can't see what I'm missing
(reraised from PacktPublishing/Godot-Game-Engine-Projects#29)
I'm following the SpaceRocks project but I'm having an issue with detecting Player / Rock collisions. This is almost certainly something I'm doing wrong, I'd just appreciate a pointer as to what that might be.
I've connected a signal to a C# (yes I'm using C#) method on
Player.on_body_entered
:The problem is this signal's method is never invoked. I've put a breakpoint at the start of this method and it's just never hit when the player ship and rock meet. I also never see the debug output.
My code for my current attempt
JohnLudlow / GodotTraining / SpackeRocks
Things I've already checked
The player has contact monitor enabled:
The player has a collision shape:
The rocks have a collision shape
Thanks for the quick response and that's a good thing to check. If I remember correctly, the project in the book doesn't ask you to do anything specific with the collision layers.
Collisions between rocks and bullets (which are Area2D's) work fine (which also suggests the collision shape is correct)
I've downloaded the sample project and compared property-by-property and can't see what I'm missing
I've made a much simpler project to test collisions between RigidBody2D objects: JohnLudlow / GodotTraining / 2dColisionTester and collisions do trigger the signal.
Conclusion
So I'm pretty sure this is something obvious I'm missing but I can't see what so I'd really appreciate a pointer or two.
The text was updated successfully, but these errors were encountered: