- Home /
Question by
Vire · Jan 15, 2014 at 08:59 AM ·
inputinputmanager360 controller
Joystick Right-Stick Input for Rotating Camera
I've been trying to get my camera to rotate using an XBOX360 Controller Joystick. The right stick.
I've set everything up in the input editor and modified my code to accept joystick input. It simply... does not work. No reason for it not to.
void LateUpdate()
{
h = Input.GetAxis("Horizontal");
s = Input.GetAxis("Strafe");
mh = Input.GetAxis("Mouse X");
mv = Input.GetAxis("Mouse Y");
jh = Input.GetAxis("JoyX");
jv = Input.GetAxis("JoyY");
FreeCamera(mh, mv, jh, jv);
if(Input.GetButton("CameraTurn"))
{
FollowCamera();
}
if(s > deadZone || s < -deadZone || h < deadZone || h > -deadZone)
{
camera.transform.RotateAround(target.transform.position, Vector3.up, s * -playerMovement.turnSpeed * Time.deltaTime);
}
}
void FreeCamera(float mh, float mv, float jh, float jv)
{
float rotationAmount;
if(Input.GetButton("CameraOrbit") && (mh > deadZone || mh < -deadZone || mv > deadZone || mv < -deadZone || jh > deadZone || jh < -deadZone || jv > deadZone || jv < -deadZone))
{
rotationAmount = jh * hRotateSpeed * Time.deltaTime;
camera.transform.RotateAround(target.transform.position, Vector3.up, rotationAmount);
rotationAmount = jv * -1.0f * vRotateSpeed * Time.deltaTime;
camera.transform.RotateAround(target.transform.position, cam.transform.right, rotationAmount);
}else if(Input.GetButton("CameraTurn") && (mv > deadZone || mv < -deadZone || jv > deadZone || jv < -deadZone))
{
rotationAmount = jv * -1.0f * vRotateSpeed * Time.deltaTime;
camera.transform.RotateAround(target.transform.position, cam.transform.right, rotationAmount);
}
}
Comment