0 votes

I need to rotate a rigidbody to a rotation using angular velocity. This is so I can rotate an object to the rotation of a VR controller. Currently what I am doing is taking the goal rotation and subtracting the current rotation. Since velocity is in Euler Angles, I have to convert the basis to Euler Angles using get_euler().

func _integrate_forces(state):
    var goal_rotation = goal_transform.global_transform.basis.get_euler()
    var current_rotation = global_transform.basis.get_euler()
    var rotation = goal_rotation - current_rotation
    state.angular_velocity = rotation

After rotating past a certain point the rigidbody starts spinning in the wrong way. How do I rotate a rigdbody to a rotation using angular velocity?

Godot version 3.2.3 Stable
in Engine by (19 points)

1 Answer

0 votes
Best answer

I have an alternative to my own answer. I have a StaticBody (any physics body will work) as a child of what I want my goal rotation is. Created a 6DofJoint and connect the RigidBody I want to rotate to the StaticBody. I disabled the Linear and Angular limits and enabled only Angular Spring. I set stiffness to 2 and dampen to 0.05.

by (19 points)
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 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 webmaster@godotengine.org with your username.