-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
3d game tutorial bug on squashing #8333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (mob.IsQueuedForDeletion() && Vector3.Up.Dot(collision.GetNormal()) > 0.1f) | |
| if (!mob.IsQueuedForDeletion() && Vector3.Up.Dot(collision.GetNormal()) > 0.1f) |
|
Thanks for the contribution nonetheless! |
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.