Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Andrea |
For some misterious reason the function add_torque()
on my rigidbody3D does not work anymore, the funny thing is that it was working before i started modifying some other area of the project, and now that i come back i dont know what possibly went wrong!
I checked everything, the body is in Rigid mode, no axis lock, changing the angular damp produces no results, changing mass and torque amount doesnt change a thing, custom integration, continuous cd, contact monitor, sleep, i checked and unchecked everything with no results.
The code is as follow, but i dont think there is anything bad with (as it is quite simple.
add_central_force()
works, also the results from the print() gives values which are greater than (0,0,0)
func _integrate_forces(state):
apply_gravity()
apply_controls()
func apply_gravity():
add_central_force(orbiting_body.mass*mass*world.G/pow(body_direction.length(),2)*body_direction.normalized())
func apply_controls():
if pitching!=0:
add_torque(transform.basis.x*pitching*rotating_speed)
print(transform.basis.x*pitching*rotating_speed)
if yawing!=0:
add_torque(transform.basis.y*yawing*rotating_speed)
print(transform.basis.y*yawing*rotating_speed)
if rolling!=0:
add_torque(transform.basis.z*rolling*rotating_speed)
print(transform.basis.z*rolling*rotating_speed)
if accelerating!=0:
throttle+=0.02*accelerating
throttle=max(0,min(1,throttle))
if throttle>0:
add_central_force(max_acceleration*throttle*($Nose.global_transform.origin-global_transform.origin))
Any thoughts on what could i check?
EDIT
if instead of using add_torque, I rotate the object using rotate(transform.basis.x*pitching, 1)
, the rotation remains applied only for 1 frame, it then reverts back immediatly to the original un-rotated status.
It’s like there is something that reverts the rotation back at every frame!