self.transform assignment freezes rigid body

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By z80

Hello,

I have a RigidBody node I’d like to simulate translational movements only. So I’ve locked the rotational degrees of freedom using 3 appropriate check boxes. The problem is it seems I can’t change orientation anyhow without freezing the node movement. For example, I’d like to change the body orientation in the following way.

var t: Transform = self.transform
t.basis = _q # "_q" is computed in other place
self.transform = t

The body freezes in space. I.e. it rotates the way I rotate it but all physics gets disabled.

And it doesn’t matter if I change transform at all. Even a simple

self.transform = self.transform 

Freezes the body movements. It just stays in place as if it was a static body.

Is there any way to change rigid body orientation and keep physics simulation running? I find it a little bit confusing that assigning a transform even its own value stops the simulation.

Further testing showed that the assignment disables simulation for this exact frame. For example, if “self.transform = self.transform” is called once, only one frame is not simulated. But if it is called inside _process(delta), (i.e. for every frame), the body movement stops completely.

:bust_in_silhouette: Reply From: klaas

Hi,
have a look at _integrate_forces
with this you can effectivly alter the outcome of physics calculation e.g. disable angular velocity.

https://docs.godotengine.org/en/stable/classes/class_rigidbody.html#class-rigidbody-method-integrate-forces

https://docs.godotengine.org/en/stable/classes/class_physicsdirectbodystate.html#class-physicsdirectbodystate

Thanks a lot!

z80 | 2020-09-02 05:17