diff options
author | PouleyKetchoupp <pouleyketchoup@gmail.com> | 2021-10-22 11:56:00 -0700 |
---|---|---|
committer | PouleyKetchoupp <pouleyketchoup@gmail.com> | 2021-11-08 16:17:57 -0700 |
commit | fc8c766ef93454e43a5a31fd7fb0a0b07946e32b (patch) | |
tree | daf19d332259ad3c627b6948395920b4a616a327 /servers/physics_2d/godot_body_2d.cpp | |
parent | 25bea735449d4e762e3c5f6b960d5f5b9cf79ac1 (diff) |
Expose local center of mass in physics servers
Center of mass in body's local space is more useful than the transformed
one in some cases, like drawing its position for debug.
It's especially useful to get the generated local center of mass when
in auto mode (by default).
Physics Server BODY_PARAM_CENTER_OF_MASS:
Now always returns the local center of mass, instead of setting a local
center of mass and getting a transformed one.
This causes compatibility breaking, but it makes more sense for the
parameter to be consistent between getter and setter.
Direct Body State:
There are now two properties, because both of them can be useful in
different situations.
center_of_mass: relative position in global coordinates (same as before)
center_of_mass_local: position in local coordinates
Diffstat (limited to 'servers/physics_2d/godot_body_2d.cpp')
-rw-r--r-- | servers/physics_2d/godot_body_2d.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/servers/physics_2d/godot_body_2d.cpp b/servers/physics_2d/godot_body_2d.cpp index 109914d585..442c580920 100644 --- a/servers/physics_2d/godot_body_2d.cpp +++ b/servers/physics_2d/godot_body_2d.cpp @@ -221,7 +221,7 @@ Variant GodotBody2D::get_param(PhysicsServer2D::BodyParameter p_param) const { return inertia; } case PhysicsServer2D::BODY_PARAM_CENTER_OF_MASS: { - return center_of_mass; + return center_of_mass_local; } case PhysicsServer2D::BODY_PARAM_GRAVITY_SCALE: { return gravity_scale; |