godotengine / godot-docs

Godot Engine official documentation
https://docs.godotengine.org
Other
3.78k stars 3.07k forks source link

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

Open anmolp476 opened 4 months ago

anmolp476 commented 4 months ago

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

fmnjose commented 4 months ago

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: