- Home /
Setting up a rotation joystick
Hey guys, I've lately implemented a movement joystick and now am trying to make a rotation joystick (rotate 2d character on z axis) but I am a little stuck and was hoping to get some help here. I've tried using the LookAt, I got the input using CrossPlatformInputManager.GetAxis(RotateX) and same with Y and stored them in V and H floats. then stored them in a Vector3 and using LookAt I set a quaternion to rotate to that position, the problem is that the rotation is too small since the values im getting from the GetAxis is -1 to 1, so it rotates to 359 or 1 only
EDIT 2 : I was able to rotate the character using the localEulerAngles:
Vector3 rotation = new Vector3(CrossPlatformInputManager.GetAxis ("RotateX") * 180,
CrossPlatformInputManager.GetAxis ("RotateY") * 180, 0f);
transform.localEulerAngles = new Vector3 (0f,0f, rotation.x + rotation.y);
I'm stuck right here, the character rotates although it rotates crazily around, does anyone know how to make this work?
Do you still need this solution? I have more then one script for this, they all work fine but the rotation is not completely smooth. Im in the proccess of resolving that issue
Your answer