Hi,
I just started some code that is supposed to simulate a real world fidget spinner. After scribbling the system on paper i thought i had a good solution, and it works fine for some angles except around certain angles where it starts to show some weird behaviour sort of changing direction. I can’t figure out what’s causing this. Pasting code below.
if (Input.GetMouseButton(0))
{
Debug.Log(transform.rotation.z.ToString());
Vector3 v_deltaInput = lastInput - Input.mousePosition;
Vector3 v_unitTheta = -Mathf.Sin(transform.rotation.z) * Vector3.right + Mathf.Cos(transform.rotation.z) * Vector3.up;
f_projection = Vector3.Dot(v_unitTheta, v_deltaInput);
transform.Rotate(Vector3.fwd, f_projection);
lastInput = Input.mousePosition;
}
else {
transform.Rotate(Vector3.fwd, f_projection);
}
}