This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Hi...,

I have a 3D RigidBody with a locked Y-Rotation-Axis (Axis Lock Angular Y). All other linear and angular axes are unlocked.

I want to set the y-rotation by code myself. The translation and rotation of the unlocked axes should be calculated by the physics engine.

I can change rotation.y in _physics_process(delta) or _process(delta), which rotates in y correctly, but this stops the translation and rotation of the unlocked axes, calculated by the physics engine. Another try to change the translation in _integrate_forces(state) doesn't do anything.

Any ideas?

Thanks

Mike

in Engine by (169 points)
edited by

1 Answer

+1 vote
Best answer

Hi,
use the RigidBody mode "character"
then modify the transform in the bodystate

func _integrate_forces( state ):
    state.transform.basis = state.transform.basis.rotated(Vector3.UP,the_rotation)
by (4,088 points)
selected by

Hi klaas,

state.transform.basis = state.transform.basis.rotated(Vector3.UP,the_rotation)

fixed my problem. I leave the mode as Rigid and not Character, because I need the automatic physics rotation in x, and z.

Thank you so much, I've learnd something new, and I think I like Godot more and more, Cheers

Mike

Hi i am new to godot and i have done this but after a few rotation my input keys wont work.

Hi,
this issue seems to be related to another problem.

Can you provide code to replicate the issue?

Thanks so much for the answer! I was struggling with rotating a rigidbody as it wasn't rotating around its own axis. Your solution works.
:)

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 Frequently asked questions and 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 [email protected] with your username.