0 votes

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:

setappliedforce(Vector2())
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.

asked Apr 28 in Engine by Robotex (138 points)
edited Apr 28 by Robotex

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.