Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Fixed GodotPhysicsDirectBodyState2D::get_velocity_at_local_position() ignoring custom center_of_mass.

Edward Chan8322a6ae40d3
diff --git a/modules/godot_physics_2d/godot_body_2d.h b/modules/godot_physics_2d/godot_body_2d.h
index 2f328ad5412..58a16b6b379 100644
--- a/modules/godot_physics_2d/godot_body_2d.h
+++ b/modules/godot_physics_2d/godot_body_2d.h
@@ -321,7 +321,7 @@ public:
void integrate_velocities(real_t p_step);
_FORCE_INLINE_ Vector2 get_velocity_in_local_point(const Vector2 &rel_pos) const {
- return linear_velocity + Vector2(-angular_velocity * rel_pos.y, angular_velocity * rel_pos.x);
+ return linear_velocity + Vector2(-angular_velocity * (rel_pos.y - center_of_mass.y), angular_velocity * (rel_pos.x - center_of_mass.x));
}
_FORCE_INLINE_ Vector2 get_motion() const {