I want to build my RigidBody2D from different pieces, each of them has own mass. Center of mass point calculated and depends from pieces mass.
I implemented it as RigidBody2D with few CollisionPolygon2D with each script attached that defines mass and main script of root object calculates center of mass point. I'm controlling my body by functions:
setappliedforce(thrust.rotated(rotation) + gravity)
setappliedtorque(rotationdir * spinthrust)
But how to do the same with calculated center of mass point?
I see function
void add_force(offset: Vector2, force: Vector2)
but I don't understand how to use it in each frame. Should I clear all forces and than set it by add_force?
I used that:
add_force(Vector2(0, 30), (thrust.rotated(rotation) + gravity))
but object moves similar as force applied to center and without rotation.
Maybe I can calculate result force and torque from all forces applied to different points of my body.