Skip to content

Conversation

@toniuyt123
Copy link

@toniuyt123 toniuyt123 commented Oct 26, 2023

The collision detection with the enemies in the "Your first 3D Game" tutorial is written in way that makes it possible for the squash event to be emitted multiple times. This happened to me regularly and messed up the score tracking afterwards because it incremented the score by more than one. I am not sure if this is the best to do this or to handle collisions in Godot 4 in general as I am still rather new but I thought I'd submit it as an issue here.

Copy link
Member

@AThousandShips AThousandShips left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this solution, the correct solution IMO is to do break after the squash part, like is done in the 2D demo, as is done in:

{
// We check that we are hitting it from above.
if (Vector3.Up.Dot(collision.GetNormal()) > 0.1f)
if (mob.IsQueuedForDeletion() && Vector3.Up.Dot(collision.GetNormal()) > 0.1f)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (mob.IsQueuedForDeletion() && Vector3.Up.Dot(collision.GetNormal()) > 0.1f)
if (!mob.IsQueuedForDeletion() && Vector3.Up.Dot(collision.GetNormal()) > 0.1f)

You've got it backwards here

{
// We check that we are hitting it from above.
if (Vector3.Up.Dot(collision.GetNormal()) > 0.1f)
if (mob.IsQueuedForDeletion() && Vector3.Up.Dot(collision.GetNormal()) > 0.1f)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (mob.IsQueuedForDeletion() && Vector3.Up.Dot(collision.GetNormal()) > 0.1f)
if (!mob.IsQueuedForDeletion() && Vector3.Up.Dot(collision.GetNormal()) > 0.1f)

@Calinou Calinou added bug area:getting started Issues and PRs related to the Getting Started section of the documentation labels Nov 9, 2023
@Calinou
Copy link
Member

Calinou commented Nov 9, 2023

Thanks for the contribution nonetheless!

@Calinou Calinou closed this Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

archived area:getting started Issues and PRs related to the Getting Started section of the documentation bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants