Making a RigidBody rotate still with 'apply_impulse'

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Mudley
:warning: Old Version Published before Godot 3 was released.

Is it possible to make a RigidBody rotate still using ‘apply_impulse’? My attempts resulted on it rotating but moving out of place.

:bust_in_silhouette: Reply From: quinno

No. apply_impulse is like poking the object, you can make it spin/rotate but you’re always going to impart thrust too.

Godot 3.0 only (I think): If you implement the _integrate_forces virtual method, you can call apply_torque_impulse on the state object. This should do what you want. see: http://docs.godotengine.org/en/latest/classes/class_rigidbody.html#class-rigidbody-integrate-forces

You could attach the body to a joint (to allow it to rotate only) if you want no movement at all.

Worst case, you can set the linear/angular velocity manually.

Worst case, you can set the linear/angular velocity manually.

This is what I am trying to avoid, I asked this because there was no function like ‘set_applied_torque’ like its 2D counterpart has.

Thanks anyway, one more reason to be hyped for 3.0.

Mudley | 2017-06-15 03:24

:bust_in_silhouette: Reply From: wombatstampede

I posted a sample project in the forum which does this (in godot 2.1.3):
https://godotdevelopers.org/forum/discussion/18480/godot-3d-vector-physics-cheat-sheet

physics/vector 3d sample project

In short:
You need to apply impulses on both “ends” in opposite directions. And you should wait a short time (i.e. 0.1sec) after start for physics to settle down before applying impulses.