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

Allow implementing custom gravity in Area2D and Area3D #7850

Closed
aaronfranke opened this issue Sep 25, 2023 · 2 comments
Closed

Allow implementing custom gravity in Area2D and Area3D #7850

aaronfranke opened this issue Sep 25, 2023 · 2 comments

Comments

@aaronfranke
Copy link
Member

aaronfranke commented Sep 25, 2023

Describe the project you are working on

I am working on an interoperable gravity standard, with many types of gravity. The goal is to be able to replicate everything in Super Mario Galaxy, and potentially more types of gravity.

Describe the problem or limitation you are having in your project

I would like to be able to implement arbitrary gravity types using Area3D nodes, but Godot only supports directional and point gravity. Godot does not provide any way to extend Area3D with more gravity types.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

  1. Replace the is point boolean with a gravity type enum. The existing boolean doesn't really make sense - even though Godot only has 2 gravity types, there are more than 2 conceivable types, so this should be an enum.
  2. Implement a new gravity type called Target that allows defining the target point for custom gravity as the return value from a callback method that runs for every object in the gravity field every frame. This allows determining different gravity directions for different parts of the gravitational field.

To be clear, most of the heavy lifting would be done by the user-defined callback method. This proposal is about improving the engine code to allow the user to perform advanced customization.

I personally only need this for Area3D, but for consistency we should do the same with Area2D.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

PR: godotengine/godot#82878 branch: https://github.com/aaronfranke/godot/tree/gravity-target

If this enhancement will not be used often, can it be worked around with a few lines of script?

I think this won't be used often, most users are not trying to implement Super Mario Galaxy style games with custom gravity. This could kinda be worked around by manually applying forces to rigid bodies, but that would be bypassing the way the engine usually applies gravity, would not play well with the Area node's space override system, and would take many lines. The goal of this proposal is to make it easier to extend Area's gravity with script.

Is there a reason why this should be core and not an add-on in the asset library?

Area2D and Area3D having gravity is a core feature, we should allow extending it with more gravity types.

@aaronfranke aaronfranke added this to the 4.x milestone Sep 25, 2023
@Mickeon
Copy link

Mickeon commented Sep 27, 2023

This is a very interesting feature, but to be honest it sounds way too situational to have in core, at least to me.

@Calinou
Copy link
Member

Calinou commented Mar 30, 2024

Closing in favor of #5714, which is very similar.

@Calinou Calinou closed this as completed Mar 30, 2024
@Calinou Calinou removed this from the 4.x milestone Mar 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants