-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Simplify the PhysicsBodies interface and its methods #1384
Comments
What you're proposing sounds similar to what Unity does/did, Which is to make everything a Rigidbody and let the devs deal with the pains that causes when you want custom integration. I'd rather we rename the RigidBody modes, (since the Kinematic Mode is in fact a Kinematic__s__ mode, not a KinematicBody mode.) than to make vast changes under the hood to how these bodies are treated. A kinematic body is NOT a rigidbody with infinite mass or similar. And it should really stay that way. |
@TheDuriel I'm not suggesting that we remove any of the functionality, I'm suggesting simplifying the current implementation. For example, instead of using |
That would literally not lead to the same behavior. |
If it's implemented correctly it would. |
How would one, in this new system, implement responses to individual collision events as you are causing them? |
I like the idea to merge RigidBody and StaticBody. I'm worrying about merging also the As I envision it, the kinematic body algorithm should be 100% customizable, and be able to just set the body velocity is really not enough. If a game just needs a character that walk around, can always use a RigidBody with the mode set as |
For RigidBody (and 2D) it's painful for player-controlled objects that it doesn't have an API for detecting being on the ground, getting collision normal. For all that need to get PhysicsDirectSpace and do IntersectShape (for which normal is available only for closest collision) or IntersectRaycast (for which needs many casts or it doesn't detect full shapes bottom collision cases). |
You actually don't. The State of the rigidbodies _integrate forces provides the necessary data without additional raycasting being needed. |
Yes, but that's the problem. Why for simple movement I need to get into another callback that works async? |
If you're using a RigidBody you are already past the point of simple movement. And its one line of code to get the collision normals dot product and compare it. So its not much different from what a kinematic body offers. In fact, you could even wrap it in your own is_on_floor(state) function. |
I have gone also very not-simple roads on RigidBody and I know well how unpleasant it can be. Because of such lack of access from RigidBody2D I once was forced to create my own RigidKinematicBody2D. |
Merging RigidBody and StaticBody is fine, I don't think there's any real need for those to be separate. But for KinematicBody setting |
I'm somewhat bothered by this reply. Yeah, if something is implemented a certain way, it could lead to the same behavior as another way... but you could say the same about using many Sprite3D nodes to build a character model. So... I'm kinda curious, and kinda suspicious of this answer. How much research have you done on this point? Have you actually tested that a certain implementation would lead to the same results? |
It sounds like merging RigidBody and KinematicBody would remove a basic but customizable/extensible thing, and replace it with something complex, where you have to disable or work around all of its extra features if you want to make something custom. That doesn't sound like an improvement to me. |
I think there is a really bad idea to merge kinematic bodies into rigidbodies. |
For now, KinematicBody2D can only push RigidBody2D, and the RigidBody2D will keep the velocity. I would like set a KinematicBody2D's linear_velocity directly(or use move_and_slide), and it will push another KinematicBody2D away that will not keep the velocity. Can it be easily applied after this change? |
@bnyu This can be integrated. Though, if you need a In order to allow a |
What looks simpler for the engine developer isn't necessarily good for the game developer. Sure, merging these things would make some things easier for the former, but it would cause great confusion for the latter. |
To clarify, the proposal is to simplify things for the game developer (not the engine developer). For example, currently, a Similarly, functions like |
This doesn't make anything easier for game or engine developers. Kinematic bodies represent an abstract API. Merging it with RigidBodies which literally do different stuff all together does not make this API easier to use. The Kinematic mode of a RigidBody is not identical to a KinematicBody. Nor is it intended to be used as one. It is there for when you need to momentarily acquire the properties of the Mode. The only thing I see happening here is: Two relatively huge classes get merged into one big mess. The API becomes harder to use due to an abundance of properties and functions you won't care about most of the time. And the behavior of Kinematic Bodies be literally different. |
Merging all the PhysicsBody types is like merging Node2D and Control. They don't do the same thing. They're not supposed to do the same thing. And you either loose functionality that users have to re-implement in script/code, or you end up with a bloated Node with too many options you don't care about most of the time. Well we're at it, why don't we make all the Joint types just one node with different options? Make the Light types one node? Combine CPUParticles and GPUParticles? (this one might be okay, though, since they're for almost the same thing) Considering how many different nodes are separated out by functionality so they don't all have a bunch of extra options you just ignore for most use cases, this seems not only bad for usability, but also inconsistent with the rest of the engine's design. The entire point of KinematicBody is that it doesn't have physics interactions built-in, and it lets you implement your own using It seems more reasonable to remove RigidBody's extra modes. Though, as @TheDuriel mentioned, they can be used for PhysicsBodies that need to change modes while the game is running, so maybe just update the docs to mention what they're good for? Additionally, from what other people said, it seems they don't behave quite like their Node counterparts, as the docs claim. Maybe this is causing some of the disagreement? Also, I just remembered one thing that StaticBody2Ds can do that other PhysicsBodies can't: you can scale them using their transform and it scales them up correctly. This contradicts the docs, but it works in practice (docs should probably be updated rather than "fixing" this). |
Superseded by #2184. |
Describe the project you are working on:
Any game that uses
PhysicsBodies
.Describe the problem or limitation you are having in your project:
Currently, Godot has three types of
PhysicsBody
:RigidBody
,KinematicBody
andStaticBody
.RigidBody
also has four modes:Rigid
,Character
,Kinematic
andStatic
. Not only is this confusing, but there are functions available inKinematicBody
that are not available to aRigidBody
and visa versa. Furthermore, functions likeKinematicBody's
move_and_slide()
have lots of parameters that can be confusing and don't always do what is expected (most notablystop_on_slope
).Describe the feature / enhancement and how it helps to overcome the problem or limitation:
A
KinematicBody
is just aRigidBody
with infinite mass (or zero inverse mass). AStaticBody
is just aKinematicBody
with zero (or constant) velocity. The same way aRigidBody
inCharacter
mode doesn't rotate (because it effectively has infinite rotational inertia, or zero inverse rotational inertia). Furthermore, sliding and snapping are really justPhysicsMaterial
properties, andstop_on_slope
can be programmed in to work as expected.Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
A
RigidBody
already has the modes needed, so we just need to make the functions that are available toKinematicBody
available to aRigidBody
(inKinematic
mode). At the same time, since all of the parameters to themove_and_collide()
,move_and_slide()
andmove_and_slide_with_snap()
can be made properties of thePhysicsBody
, thePhysicsMaterial
, or, in the case of theup_direction
andfloor_max_angle
, theSpace
orArea
. These methods can then be removed, because they will no longer be needed.If this enhancement will not be used often, can it be worked around with a few lines of script?:
No, this will actually simplify scripts.
Is there a reason why this should be core and not an add-on in the asset library?:
This is a change to how core physics works.
Finally, its worth noting that these changes should make implementing some of the other proposals (e.g. #236, #364, #628, #667 #740) easier.
The text was updated successfully, but these errors were encountered: