I have a spaceship with a rigidBody i can fly around with.
This works really well.
But when i now want to make it physical, giving it a collider, i cannot rotate any longer.
I do this with some triggers inside FixedUpdate()
void FixedUpdate()
{
// In the physics update...
// Add rudder yaw torque when steering left/right
_cacheRigidbody.AddRelativeTorque(new Vector3(0, Input.GetAxis("Yaw") * yawRate * _cacheRigidbody.mass, 0));
if (!switchTurnMove)
{
// Add relative rotational roll torque when steering left/right
_cacheRigidbody.AddRelativeTorque(new Vector3(0, 0, -Input.GetAxis("Roll") * rollRate * _cacheRigidbody.mass));
// Add pitch torque when steering up/down
_cacheRigidbody.AddRelativeTorque(new Vector3(Input.GetAxis("Pitch") * pitchRate * _cacheRigidbody.mass, 0, 0));
} else
{
// Add force without rotational torque
_cacheRigidbody.AddRelativeForce(Vector3.left * stabilizingRate * -Input.GetAxis("Roll") * _cacheRigidbody.mass);
// Add force without rotational torque
_cacheRigidbody.AddRelativeForce(Vector3.up * stabilizingRate * Input.GetAxis("Pitch") * _cacheRigidbody.mass);
}
}
As you can see i have two different steering behaviours. The first one is rolling and pitching, the second is yawing to 2 angles. AddRelativeForce works well, while AddRelativeTorque does not show any reaction any longer.
Now my object collides wonderful, but no longer steers.
What am i doing wrong ?