Skip to content
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

Please remove this code block, or add some explanation to it #9355

Closed
anmolp476 opened this issue May 10, 2024 · 1 comment · Fixed by #9382
Closed

Please remove this code block, or add some explanation to it #9355

anmolp476 opened this issue May 10, 2024 · 1 comment · Fixed by #9382
Labels
area:getting started Issues and PRs related to the Getting Started section of the documentation content:example code Issues and PRs involving code examples enhancement

Comments

@anmolp476
Copy link

Your Godot version: 4.2

Issue description: I am confused what this code block is there for. I've read older posts from the r/godot subreddit, and one comment is suggesting that it may be due to the collision between the floor and the player being handled elsewhere. Although I can't see that anymore. Overall, im just super confused what this code block is for.

# If the collision is with ground
		if collision.get_collider() == null:
			continue

URL to the documentation page (if already existing): https://docs.godotengine.org/en/stable/getting_started/first_3d_game/06.jump_and_squash.html

The referenced code block is in the Squashing monsters section

@skyace65 skyace65 added the area:getting started Issues and PRs related to the Getting Started section of the documentation label May 11, 2024
@fmnjose
Copy link
Contributor

fmnjose commented May 15, 2024

Just stumbled into this on the documentation as well. The comment is misleading.
This block of code is not to identify if the collision is with the ground, but is indeed to prevent a null pointer that occurs when there are multiple collisions with an enemy in one single frame.

Without this block of code, if there is more than one collision with a mob detected in a single frame, the following will happen:

  • The first collision calls the squash function and deletes the mob object
  • The second collision will try to get the collider, which will then be null because the object was just deleted
  • Calling the collision.getCollider().is_in_group() will fail with a null pointer exception.

fmnjose added a commit to fmnjose/godot-docs that referenced this issue May 15, 2024
On the collision processing code (Chapter 6 - Jumping and squashing monsters) there is a misleading comment saying that the collision.get_collider() == null has the purpose of checking for a collision with the ground.

This addresses the following open issue: godotengine#9355
Evanev7 added a commit to Evanev7/godot-docs that referenced this issue May 17, 2024
Addressed issue godotengine#9355, and fixed a typo.
@tetrapod00 tetrapod00 added the content:example code Issues and PRs involving code examples label Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:getting started Issues and PRs related to the Getting Started section of the documentation content:example code Issues and PRs involving code examples enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants