Hi,
So over the past few months I’ve encountered a seriously frustrating problem: I’ve made spinning wheel (3D object) that is a child of my camera which has a mouselook script on it. When the wheel is NOT a child object, it spins perfectly and upright, but as a child object, it’s rotation is affected by the parent no matter what I try.
This is the mouselook code on the camera:
- rotationX += Input.GetAxis(“Mouse X”) * lookSpeed;
- rotationY += Input.GetAxis(“Mouse Y”) * lookSpeed;
- transform.localRotation = Quaternion.AngleAxis(rotationX, Vector3.up);
- transform.localRotation *= Quaternion.AngleAxis(rotationY, Vector3.left);
The wheel spins in relation to where and how fast I look around with the camera instead of simply staying in front of the camera and spinning on it’s own y axis. I’m using AddTorque and I’ve tried with adding the torque using Vector3 or it’s transform (see below) and it’s the same result!! I’m going crazy over here. How come it’s completely impossible to do something so painfully simple in Unity??? If anybody knows how to make something like this work please let me know!!!
here’s the spin wheel code:
void Awake()
{
gO = GetComponent<Rigidbody>();
gO.angularDrag = Random.Range(0f, 1.5f);
gO.AddTorque(transform.up * torque, ForceMode.Impulse );
}