-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Physics nodes reorganization #48908
Physics nodes reorganization #48908
Conversation
BTW can we get docs telling us how to convert move_and_slide() to move_and_collide() - I tried passing the velocity * delta to move and collide, which most tutorials seem to recommend, and got completely different behavior than move_and_slide(), do they use different parameters other than one having the delta baked in and the other not? |
@Zireael07 If you mean that
|
No, I do want it to stop on obstacles. I mean I get completely different behavior, almost as though the velocities were much larger... |
@Zireael07 That seems strange. Could you open an issue with a MRP so I or someone else can have a look to your use case? It's a bit off-topic to discuss it here. |
scene/2d/physics_body_2d.cpp
Outdated
ClassDB::bind_method(D_METHOD("move_and_collide", "rel_vec", "infinite_inertia", "exclude_raycast_shapes", "test_only"), &PhysicsBody2D::_move, DEFVAL(true), DEFVAL(true), DEFVAL(false)); | ||
ClassDB::bind_method(D_METHOD("test_move", "from", "rel_vec", "infinite_inertia", "exclude_raycast_shapes", "collision"), &PhysicsBody2D::test_move, DEFVAL(true), DEFVAL(true), DEFVAL(Variant())); | ||
|
||
ClassDB::bind_method(D_METHOD("set_safe_margin", "pixels"), &PhysicsBody2D::set_safe_margin); |
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.
I know this kind of is a nitpick, but safe margin exists as a hack because of Bullet. If Bullet is being removed, I think we should probably just get rid of it, and pass the margin as a default parameter of move_and_collide. this way we also pollute the base class less.
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.
Since you are going to remove Bullet now, I guess you like to reread this.
(I assume that decision hasn't been taken at the time)
Err, sorry, approved by accident, but it looks fanastic so i guess its ok anyway. I would change the safe margin, but depends on what you think regarding it most likely breaking in Bullet. TBH I would just not care about Bullet at this point. |
e6ec0c3
to
8773cb4
Compare
@reduz I've just pushed two changes based on your feedback and our discussion on rocketchat:
Safe margin property on
|
8773cb4
to
1463fc3
Compare
Supersedes #43073? |
1463fc3
to
90cfe62
Compare
PhysicsBody now has methods move_and_collide/test_move and needed properties for these methods: safe margin, locked axes (3D only). Moved collision_exceptions from StaticBody to PhysicsBody for 3D (same as 2D, and conforms to documentation). RigidBody doesn't have test_motion method anymore, it's now redundant with PhysicsBody.test_move.
- snap property to replace move_and_slide_with_snap() - floor_max_angle, stop_on_slope, infinite_inertia, max_slides, up_direction properties to replace arguments from move_and_slide() - up direction now defaults to Vector3.UP and Vector2.UP
MODE_DYNAMIC instead of MODE_RIGID MODE_DYNAMIC_LOCKED instead of MODE_CHARACTER No more special case for sleeping behavior for MODE_DYNAMIC_LOCKED (MODE_CHARACTER was forcing the body not to sleep, which is redundant with can_sleep and wasn't done in Bullet).
Does the same thing as simulate motion from RigidBody in Kinematic mode, and CharacterBody (previously KinematicBody). Added support for constant linear/angular velocity with kinematic_motion in StaticBody, which moves the body in physics. Updated documentation for StaticBody and CharacterBody to describe their functionalities more accurately.
Safe margin property on CharacterBody only, used as argument in move_and_collide. Removed kinematic_safe_margin in 3D physics server, not really useful and now harmonized with 2D.
CharacterBody has a linear_velocity property to replace the argument in move_and_slide. StaticBody handles reporting linear/angular velocity correctly when kinematic motion is used (in 3D, used in vehicle and navigation).
90cfe62
to
23abac9
Compare
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.
That's a great step in the right direction, let's see how the user feedback is and iterate on it for 4.0.
Thanks! |
|
Implements godotengine/godot-proposals#2184 for 2D and 3D physics.
Named things a bit differently from the original proposal in order to alleviate possible confusion reported by the community (more details in godotengine/godot-proposals#2184 (comment)).
The general idea is to keep consistent naming all over the API to make documentation easier, with names that match standards from physics engines:
Dynamic = can move, receive forces and be pushed around
Kinematic = can't be pushed, can move and push dynamic bodies along the path
Static = can't be pushed, can move by teleport only
Character = specific kinematic character controller functionalities
Changes are in separate commits to make review easier, but I can squash everything in the end if needed.
1.
KinematicBody
functionalities split betweenPhysicsBody
and new nodeCharacterBody
-
KinematicBody
renamedCharacterBody
, using same icons-
PhysicsBody
now has methodsmove_and_collide
/test_move
and needed properties for these methods: safe margin, locked axes (3D only).-Moved
collision_exceptions
fromStaticBody
toPhysicsBody
for 3D (now same as 2D, and conforms to documentation).-
RigidBody
doesn't havetest_motion()
method anymore, since it's now redundant withPhysicsBody.test_move()
.2. Properties instead of parameters for
move_and_slide
and removemove_and_slide_with_snap
-
snap
property to replacemove_and_slide_with_snap()
-
floor_max_angle
,stop_on_slope
,infinite_inertia
,max_slides
,up_direction
properties to replace arguments frommove_and_slide()
-Default values haven't changed, except for
up_direction
which is nowVector3.UP
andVector2.UP
since it's the most common use case (it was previously zero, and would consider everything a wall by default)-Possiblity to add more properties in the future to support different character controller use cases
3. More explanatory names for
RigidBody
modes-
MODE_DYNAMIC
instead ofMODE_RIGID
(to avoid confusion withRigidBody
node)-
MODE_DYNAMIC_LOCKED
instead ofMODE_CHARACTER
(to avoid confusion withCharacterBody
node)-No more special case for sleeping behavior for
MODE_DYNAMIC_LOCKED
(MODE_CHARACTER
was forcing the body not to sleep, which is redundant with can_sleep and wasn't done in Bullet).4. Support for
kinematic_motion
inStaticBody
-Does the same thing as simulate motion from
RigidBody
in Kinematic mode, andCharacterBody
(previouslyKinematicBody
).-Added support for constant linear/angular velocity with
kinematic_motion
inStaticBody
, which moves the body in physics (as opposed to just moving bodies in contact)-Updated documentation for
StaticBody
andCharacterBody
to describe their functionalities more accurately.