Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | rolfpancake | |
Old Version | Published before Godot 3 was released. |
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:
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?