Hey Folks, got an interesting problem.
I'm working on an iPhone game and developing some customer controllers. The left joystick makes the control character both move and rotation toward the direction of the joystick points. The right joystick is just for rotation of the character around y so that the character can rotate in place while shooting. The code for rotation in the rightJoystick is very simple:
function CharacterRotation()
{
if (rightJoystick.position != Vector2.zero)
{
rotationAmount = (minRotationSpeed + maxRotationSpeed * rightJoystick.position.magnitude) * Time.deltaTime;
aimVector = Vector3 (rightJoystick.position.x, 0, rightJoystick.position.y);
aimRotation = Quaternion.LookRotation(aimVector - focus.transform.position, Vector3.up);
focus.transform.rotation = Quaternion.Slerp(focus.transform.rotation, aimRotation, rotationAmount );
}
}
focus is a Transform that is assigned to the character mesh.
When I start the game and move the right joystick everything works great. BUT, when I start with the left joystick and move the character and then go back to the right joystick, it doesn't rotate as expected. Instead, the character will rotate once in the exact opposite direction and then not rotate at all. I played around to see what was going on and I discovered that if I comment out the character.Move ( movement ) line in the left joystick script, the rightJoystick continues to work fine. Any idea what could be going on here that's causing the problem?