Parents rotation causes children axis to change

Im making a game that includes a submarine parent object containing all of its parts as children of it. When i rotate the wheel in VR the submarine rotates using this line:

rb.AddTorque(
    transform.up * wheelRotation * speedRot * Time.deltaTime,
    ForceMode.Acceleration
);

but it results in the steering wheel changing its rotation axis so when i try to rotate it again it rotates in a different axis causing the submarine to not turn.

in Contrary when i use a lever to make the submarine dive using this line

transform.Rotate(
    transform.right * speedDive * (DiveLeverRotation - startingRotationDive) * Time.deltaTime
);

it does not change the axis of any of the children.

So i tried using transform.Rotate() to rotate the submarine instead of rigidbody.AddTorque() but same problem.

1 Answer

1

You might want to have a parent obejct for the wheel and use the wheel’s local rotation.