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
Fix body leaving area gravity influence #82961
Fix body leaving area gravity influence #82961
Conversation
6ca7a3d
to
3d13e30
Compare
3d13e30
to
3ec42f4
Compare
I made modifications in the code to solve all space override cases. To do that, I created a new field in I've seen that this PR might be in conflict with #81434 and #82470, but this PR covers more case and is more efficient since the field |
3ec42f4
to
8ef3ffa
Compare
This is definitely needed I hope it gets merged soon, because the current behavior in Godot 4 is incorrect and even unpredictable at best. |
Thank you for this fix. Would love to see this approved to go into production as soon as possible 🙏 |
Even though it's less efficient, it may actually actually makes sense to calculate Also, totally a nitpick, but I wonder if the variable name could be a bit more descriptive. Maybe something along the lines of |
Good point! Indeed I put that name to test something at first, and then totally forgot it. If you think it is really needed I can update the PR to refactor this variable name. |
Sure! I think anything that improves clarity is always worth doing, especially if it's easy to change. |
8ef3ffa
to
6bbb0ed
Compare
Looks like the requested updates are in. Are any other changes needed for the review? |
Hoping to see this pushed soon, I believe the project I'm working on is affected by this issue. My setup:
My intention was for the RigidBody2D to no longer be affected by the gravity of the Area2D, but this is not the case. It appears that the last known gravity_point_center remains "in tact" so to speak. Video of this behavior: gravity.still.active.mp4 |
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 sensible, good catch! Should this also be done to GodotAreaSoftBodyPair3D
?
Also, could you amend the commit message so it doesn't include the issue reference? You can add it to the body, just not the title.
Thanks for this PR, I think it has the right spirit but not exactly the right solution. I think the role of the newly added variable Indeed, in the current I think the fix should be just this (in each of the three - has_space_override = false;
if (result != colliding) {
+ has_space_override = false; That is, it should just be the initial value in the branch where we're checking if the area overrides anything. This also fixes the three linked issues in my testing. |
@rburing Does that still leave some possibility that a programmatic change of the Area2D's override mode could result in the connection not being removed? I might be missing something, but I think in theory:
This is why I closed my original solution here: https://github.com/godotengine/godot/pull/81434/files, since it would have a similar issue. |
@NolanDC Good point, this PR covers that case while my suggested alternative doesn't. So as #82961 (review) suggests the commit message should be updated to remove the issue number from the first line and the same approach should be applied to |
Oh thanks for all of your messages, I'll look to make the changes in @rburing right now I don't remember why, but I think there was something that made me create this new field, i'll see. |
6bbb0ed
to
492f1c2
Compare
@rburing i just tried your fix and I agree with NolanNC, the fix does not cover the case when the body is in the area while it gets deleted or disabled. I still think both |
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! LGTM.
Thanks! And congrats on your first merged Godot contribution 🎉 |
Thanks everyone, this is an important fix for me and many others. |
Hi, I've been writing a quick fix for something similar and just want to confirm if this will also fix the issue. I don't teleport my object, but I do set it to be kinematic / frozen and move it. Then when I unfreeze it in a new location, it's still got areas associated with it. My fix was to write a script function that clears areas, and do that when I set the body kinematic. https://github.com/graehu/godot/tree/body_areas_fix If this fixes that I can remove my branch. 🙂 Edit: Tested myself, this fixes the issue! thanks! |
Cherry-picked for 4.2.2. |
Cherry-picked for 4.1.4. |
Hi everyone, I'm a fairly new Godot user and just upgraded to 4.2.1. I am currently experiencing this exact problem and it's game breaking for me. It looks like this fix may not have made it into an official release yet. If that's the case, how do I go about testing it out for myself the way others on this thread seem to have? Thanks for helping out a noob :) |
@ericvennemeyer the fix is not in 4.2.1. It should be in 4.2.2, 4.1.4, and 4.3, when they are released. You should try one of the latest development releases to get the fix. |
@FeralBytes will do. Thanks for the quick response! Edit: 4.1.4 dev release fixed it for me. What a relief! Thanks again |
This pull request fixes and closes issue Area3D gravity problem in Godot 4 #77682
We solve this issue with @Wiltof by adding a check in the destructor of
GodotAreaPair3D
; if the area has a gravity override then we remove the area from the body so it is not influenced by it anymore.This solves the cases where we have a
Rigidbody3D
inside anArea3D
with a gravity override mode, when theRigidBody3D
is teleported outside the Area using itsTranform
, or when theArea3D
is disabled or deleted. TheRigidBody3D
is no longer subject to theArea3D
gravity.