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

Many of = the previous functions have gone for adding forces and torque...

currently i can only use:

func _integrate_forces(state):
    state.add_force(force_direction,Vector3())

this is fine for normal absolute force

how do i apply torque? or rotational force that rotates an object?

in Engine by (64 points)

3 Answers

0 votes
Best answer

someone on the godot facebook group has confirmed it is coming for version 3.1

closed!

by (64 points)

Strange, I was able to use torque in 3.0, it's not missing^^
I implemented _integrate_forces and used the PhysicsDirectBodyState argument, it has a function to apply torque http://docs.godotengine.org/en/3.0/classes/class_physicsdirectbodystate.html#physicsdirectbodystate.

If you need to apply torque from outside, you could make a variable that you set outside, and apply it when _integrate_forces gets called.

0 votes

You add torque to a RigidBody, not to the physics state of a RigidBody. There's a function on RigidBody itself that you can call.

by (116 points)

There is no function to add torque on the RigidBody itself. The closest would be set_axis_velocity, but it may not be the most convenient.

0 votes

You know if there is no function to add torque, maybe you could emulate it.

func add_torque(state, torque_axis):
    var force_pos = torque_axis.cross(Vector3(0,1,0)).normalized()
    var torque = torque_axis.length()
    var force_dir = force_pos.cross(torque_axis).normalized() * torque

    state.add_force(force_dir, force_pos)
    state.add_force(-force_dir, -force_pos)

state is, well state. The direction of torque_axis is the axis your adding torque about. Its length defines the strength of the torque.

Note: I made this function on the top of my head. I haven't tested it yet so bare with me.

by (3,938 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 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.