• 3D
  • Local rotation on a rigid body by applying force

Hi all !

I'm trying to understand Godot's 3D transformations systems and must admitt I'm confused, even after a lot of readings.

To try to understand it, I'm trying to apply a local rotation on a rigid body which would be a vessel into space : no gravity, but forces. I understood how to apply the local translation force (engine thrust for instance), this way : func _integrate_forces(state): if Input.is_action_pressed("thrust"): moving_vec = global_transform.basis.z * engine_power add_central_force(moving_vec)

but I cannot get how to produce a local rotation using force, rolling for example. I cannot simply use rotate_object_local() which would make it automatic, as i'm dealing with a rigid body, so I have to kind of make it manually, and though I tried a lot of combination, my vessel is always rotating randomly, I have no idea about how to do it right.

I'm conscient I'm certainly missing something basic here about transformations, sorry if it's the case.

Thanks for reading and helping though !!

Thanks for answering! That's actually what I intend to use, but "pure" torque makes an global rotation, while i'd like my rotation to be local... To make the vessel roll on itself for instance.

Ok after days of searching I found the answer amazingly simple :

rotation_vec = global_transform.basis.z * rotation_speed * Z_FRONT
		add_torque(rotation_vec)

where Z_FRONT = -1.

found it here which is to become a bible for godot's 3D Physics : https://godotforums.org/discussion/18480/godot-3d-vector-physics-cheat-sheet

Awesome! Sorry about the delay, was going to respond sooner but things got busy. I'm glad you found an answer and thanks for sharing it :smiley:

2 years later

angular_velocity = -basis.x * rotation_speed