system
1
|
|
|
 |
Attention |
Topic was automatically imported from the old Question2Answer platform. |
 |
Asked By |
DarkShroom |
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?
system
2
|
|
|
 |
Reply From: |
Kyle Szklenski |
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.
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.
Zylann | 2018-11-15 18:58
system
3
|
|
|
 |
Reply From: |
DarkShroom |
someone on the godot facebook group has confirmed it is coming for version 3.1
closed!
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 PhysicsDirectBodyState — Godot Engine (3.0) documentation in English.
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.
Zylann | 2018-11-15 18:56
system
4
|
|
|
 |
Reply From: |
SIsilicon |
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.