-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Fix duplicate mob squash logic in 3D tutorial (Your first 3D game) #7767
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
|
Updated the PR with periods in comments, as well as adjusted the wording of the explanation. Screenshots updated to reflect the changes |
|
I believe this fixes: #7592 |
|
To link it add the line "Fixes: #7592" to your first message (the one at the very top) This code also now more closely matches the code in the demo project |
|
Linked the issue. Glad to see using |
|
That does seem to be the case yes |
|
@AThousandShips Is there anything else that needs to be done before this can be approved and merged? There is nothing else from my side. |
|
You'll have to see what further reviewers say |
|
I'm a beginner and also noticed this bug in the tutorial. Is that mean if I use collision detection in any calculation, a "break" or "return" is necessary in order to prevent a duplicate calculation. |
|
This would be a very helpful for onboarding new people, I also ran into this bug. @AThousandShips any chance we could get another pair of eyes from the team to review? It's definitely a nice to have and the changes seem harmless / trivial :) |
|
You can go join https://chat.godotengine.org and post it there for attention |
AThousandShips
left a comment
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.
Looks good to me, haven't verified the behavior but is the same logic as the 2D case
|
Please squash your commits into one, see here |
ee31c58 to
192fe3a
Compare
|
Thanks @AThousandShips, I have squashed my commits and rebased the changes onto the latest |
|
@AThousandShips Commit 426c83b added some whitespace changes which caused merge conflicts. I've rebased my changes again to resolve. Will require approval again (for the pipeline). Thanks! |
Calinou
left a comment
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.
Thanks!
|
Thanks for your help everyone! |
fixes #7592
Hi there! 👋
I was following the Godot 3D tutorial (Your first 3D game) and believe to have discovered a bug regarding squashing the mobs.
The collision detection section mentions
"Godot makes the body move sometimes multiple times in a row to smooth out the character's motion. So we have to loop over all collisions that may have happened."and thus checks for collisions in a loop.This current logic however will sometimes result in duplicate calls to
mob.squash(), which will double or triple count the score for one mob kill. The simple fix is tobreakout of the loop after handling the first squash occurrence to prevent further duplicate calls.Demo
Here's the demo, notice how the first two kills increased the score by two, then the last two by one. I've seen anywhere between 1-3

I've updated all occurrences of this code snippet that appear for both GDScript and C# to include the
breakstatement, as well as an explanation of the logic. The files changed are:Preview
GDScript



C#
Explanation
Please help verify whether this is the correct solution. If it is, I'm also more than happy to apply the fix to the godot-3d-dodge-the-creeps repo as well.
Thanks and have a great day!