+1 vote

Preamble

System: Godot 3 Alpha 2 on Windows 7 x64

I was tinkering with RigidBodies2D and tried to manipulate the Physics2DDirectBodyState with using

func _integrate_forces(state):
    ...some code...

It was working fine and I think I do understand the idea behind it.

What I tried to do

I wanted to create an engine with a rotating RigidBody2D and a pinjoined lever arm (another RigidBody2D). To get this thing running I added some torque in the _ready function with set_applied_torque. The other possibility seem to be using the set_angular_velocity function in the _integrate_forces method. Both ways work fine but I prefer the former (torque).

My problem is now

When I try to build an engine with a constant angular velocity (= a velocity controlled motor) I need to know the forces which act on the engines RigidBody2D - so that I can adapt the necessary torque to get a smooth constant rotation.

I hacked some control sequences which use the derivation of the current-1 velocity and some loading-factors (systems inertia) but my results aren't satisfying for my purposes:

Angular Velocity - Torque - Timeline

The blue line is the angular velocity and the orange line is the applied torque which adapts itself to the current angular acceleration (or deceleration). If I had access to the forces which are acting on my rotating engine I would be able to straighten the velocity line.

The question in short

Is it possible to get access to the forces a RigidBody2D receives?
Could the Physics2DServer-Class be a solution to this?

in Engine by (1,028 points)
edited by

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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.