Hey!
I have a barrel which rolls through addTorque in FixedUpdate().
However it pulls to the left, it pulls slower if I make the collider longer.
It seems like it affects the y-rotation but when I try to adjust it with eulerAngles the rolling-rotation speed (x) nearly stops.
transform.localEulerAngles = new Vector3(transform.localRotation.x, 0, transform.localRotation.z);
Thanks!
I don’t have any specific suggestions but I see that you are mixing quaternions (transform.localRotation.x/z) with eulerAngles.
I would suggest that you stick with : transform.rotation = Quaternion.Euler().
that is some bias, as I find that simple to work with.
Sorry, not sure about your drift, though.
I get the same problem with this code, x-rotation goes in slow-motion:
void FixedUpdate () {
rigidBody.AddTorque(transform.right * 15);
transform.rotation = Quaternion.Euler(transform.rotation.x, 0, 0);
}
You’re mixing two things badly!
AddTorque means physics will control the rotation
transform.rotation says this is the exact rotation, so it overrides anything in the physics.
I am surprised you see any rotation at all to be honest!
If you looking to ignore rotations on Y and Z you can just lock those rotations on the rigidbody
Ended up replacing the capsule collider with a sphere which stopped it drifting to the side, since locking rotation axis introduced shaking.
Thanks for your replies!