- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
KingKongFu · Dec 08, 2012 at 04:18 PM ·
camera-lookinputmanagergamepad
Change input from mouse to game pad
Ok so after a few days of messing with this I got it to work to a degree. Now it rotates and turns the way I want it to so its working great. What i did was set the axis Gravity/Dead/Sensitivity to 1/.2/1 and then did this in the code; But now the only problem is when im trying to turn on both axis at one life looking up and to the left at the same time it only moves on one axis not both. What am I doing wrong here with this? Thanks for any help with this
if (axes == RotationAxes.PadXAndY)
{
// Read the mouse input axis
if(Input.GetAxisRaw("Joy X") !=0)
{
rotationX += Input.GetAxisRaw("Joy X");
}
else
{
rotationY += Input.GetAxisRaw("Joy Y");
}
rotationX = ClampAngle (rotationX, minimumX, maximumX);
rotationY = ClampAngle (rotationY, minimumY, maximumY);
if(rotationX < -78)
{
rotationX = -78;
}
if(rotationX > 78)
{
rotationX = 78;
}
Quaternion xQuaternion = Quaternion.AngleAxis (rotationX, Vector3.up);
Quaternion yQuaternion = Quaternion.AngleAxis (rotationY, -Vector3.right);
transform.localRotation = originalRotation * xQuaternion * yQuaternion;
}
else if (axes == RotationAxes.PadX)
{
if(Input.GetAxisRaw("Joy X") != 0)
{
rotationX += Input.GetAxisRaw("Joy X");
}
rotationX = ClampAngle (rotationX, minimumX, maximumX);
if(rotationX < -78)
{
rotationX = -78;
}
if(rotationX > 78)
{
rotationX = 78;
}
Quaternion xQuaternion = Quaternion.AngleAxis (rotationX, Vector3.up);
transform.localRotation = originalRotation * xQuaternion;
}
else
{
if(Input.GetAxisRaw("Joy Y") != 0)
{
rotationY += Input.GetAxisRaw("Joy Y");
}
rotationY = ClampAngle (rotationY, minimumY, maximumY);
Quaternion yQuaternion = Quaternion.AngleAxis (-rotationY, Vector3.right);
transform.localRotation = originalRotation * yQuaternion;
}
Comment
Best Answer
Answer by Blayer98 · Dec 09, 2012 at 08:46 PM
I'm not sure how that would work, you could just keep it at Input, that's what i do when i'm creating my game.
Your answer
