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

[fixed] You no longer can take fall damage twice on the same tick #2185

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mugg91
Copy link
Contributor

@mugg91 mugg91 commented Nov 24, 2024

Status

  • READY: this PR is (to the best of your knowledge) ready to be incorporated into the game.

Description

[fixed] You no longer can take fall damage twice on the same tick

Fixes #2183

When applying the fall damage hit in FallDamage.as, the game time is saved to the blob.
At the beginning of onCollision() the code drops out if it detects that it's the same tick again so it doesn't apply the hit twice.

I'm not sure why it happens in the first place. This is just a simple fix I came up with. Of course it could be worth looking for the root of the problem.

Tested in offline and online, works correctly.

Reproduction

Build a construction like in the screenshot from the issue linked above.
You have to be standing on a corner with the block being on your left or right side of the character.
When getting bounced down, you are taking two hits for 1 heart of total damage. After this PR, it is only one hit for a total of 0.5 hearts damage

@Vam-Jam
Copy link
Member

Vam-Jam commented Nov 24, 2024

I'm not sure why it happens in the first place

It's to do with box2d, each tile is made up of segments, on a corner, you can touch two segments, so the onCollision hook gets called twice since the game reports you touched two different segments at fast enough speeds.

Entities/Common/Movement/FallDamage.as Outdated Show resolved Hide resolved
@Vam-Jam Vam-Jam added the fix Fixes a bug label Nov 24, 2024
@Vam-Jam Vam-Jam assigned Vam-Jam and unassigned Vam-Jam Nov 24, 2024
@Vam-Jam Vam-Jam added this to the Next Patch milestone Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sometimes twice the fall damage is applied
2 participants