-
-
Notifications
You must be signed in to change notification settings - Fork 21k
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
Area2D/3D Gravity: Replace point bool with a type enum, add Target gravity type #82878
Open
aaronfranke
wants to merge
2
commits into
godotengine:master
Choose a base branch
from
aaronfranke:gravity-target
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+324
−68
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aaronfranke
force-pushed
the
gravity-target
branch
from
October 5, 2023 22:13
f0365d1
to
3305748
Compare
aaronfranke
force-pushed
the
gravity-target
branch
from
December 6, 2023 05:30
3305748
to
395d4b6
Compare
aaronfranke
force-pushed
the
gravity-target
branch
from
December 29, 2023 06:23
395d4b6
to
7631c3d
Compare
aaronfranke
force-pushed
the
gravity-target
branch
2 times, most recently
from
February 22, 2024 07:50
e8f282b
to
165586b
Compare
aaronfranke
force-pushed
the
gravity-target
branch
from
March 27, 2024 00:10
165586b
to
bbd037b
Compare
This was referenced Apr 3, 2024
aaronfranke
force-pushed
the
gravity-target
branch
from
May 24, 2024 12:25
bbd037b
to
2c89dea
Compare
aaronfranke
force-pushed
the
gravity-target
branch
from
June 26, 2024 03:08
2c89dea
to
53b760c
Compare
aaronfranke
force-pushed
the
gravity-target
branch
from
August 4, 2024 05:26
53b760c
to
f02d56c
Compare
aaronfranke
force-pushed
the
gravity-target
branch
from
August 31, 2024 22:29
f02d56c
to
c5d0b07
Compare
aaronfranke
force-pushed
the
gravity-target
branch
from
October 2, 2024 23:45
c5d0b07
to
478e522
Compare
aaronfranke
force-pushed
the
gravity-target
branch
from
October 4, 2024 23:53
478e522
to
a6670e7
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements godotengine/godot-proposals#7850 and godotengine/godot-proposals#5714
In the current master branch of Godot, there are only two types of gravity: Directional and Point. Godot does not provide a way for users to implement any other gravity type. This PR allows doing this, by adding a new gravity type called Target that allows specifying the gravity's attraction target point with a callback method.
To be clear, the goal here is to add the minimum engine code required to allow user scripts to make their own gravity. The goal isn't to implement every possible gravity type in the engine code, just let users implement what they need.
This PR is split into 2 commits for easy reviewing:
Replace Area gravity point bool with a gravity type enum. This is a refactor that does not change behavior or break compatibility. A bool does not make sense here, because conceptually there are more than two possible states for gravity, and conceptually it does not make sense why one is more deserving of the true state (there could just as easily be an "is directional" boolean instead of an "is point" boolean).
Add a Target gravity type to Area for a custom target point. This adds new behavior and implements the proposal. The attraction target of the gravity is defined by the return value of the callback method. The reason it seems like there's a lot of changes is due to all the places that need to know about this (Area nodes, physics servers, physics servers wrap_mt, Godot physics engine, physics server extensions), but it's not much code compared to the existing directional and point gravity.
I have tested this in both 2D and 3D. I am planning on using this in 3D for implementing custom gravity in script.