- Home /
problem while configurating controller
i am using mouse look script to look around in my game. and i am trying to config the Thunder master joy stick , i want to use throttle to look around , it works but when i start scene it automatically starts to rotate to left side.
and keeps rotating.
i don't know what is wrong with the code that it keeps rotating ??
using UnityEngine;
using System.Collections;
[AddComponentMenu("Camera-Control/Mouse Look")]
public class MouseLook : MonoBehaviour {
public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 }
public RotationAxes axes = RotationAxes.MouseXAndY;
public float mousesensitivityX = 15F;
public float mousesensitivityY = 15F;
public float joysensitivityX = 3F;
public float joysensitivityY = 3F;
public float minimumX = -360F;
public float maximumX = 360F;
public float minimumY = -60F;
public float maximumY = 60F;
float rotationY = 0F;
void Update ()
{
float Xon = Mathf.Abs (Input.GetAxis ("Joy X"));
float Yon = Mathf.Abs (Input.GetAxis ("Joy Y"));
if (axes == RotationAxes.MouseXAndY)
{
float rotationX = transform.localEulerAngles.y + Input.GetAxis("Joy X") * mousesensitivityX;
rotationY += Input.GetAxis("Joy Y") * mousesensitivityY;
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0);
}
else if (axes == RotationAxes.MouseX)
{
if (Xon>.05){
transform.Rotate(0, Input.GetAxis("Joy X") * joysensitivityX,0);
}
transform.Rotate(0, Input.GetAxis("Mouse X") * mousesensitivityX, 0);
}
else
{
if (Yon>.05){
rotationY += Input.GetAxis("Joy Y") * joysensitivityY;
}
rotationY += Input.GetAxis("Mouse Y") * mousesensitivityY;
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
transform.localEulerAngles = new Vector3(-rotationY, transform.localEulerAngles.y, 0);
}
}
void Start ()
{
// Make the rigid body not change rotation
if (rigidbody)
rigidbody.freezeRotation = true;
}
}
i have set the input settings in input manager according to code.
if any one know the solution then please let me know how to solve this Thanks, in advance
Your answer
Follow this Question
Related Questions
Getting Joystick Input from Matricom G-Pad BX? 0 Answers
Joystick Input - "3rd Axis" etc, not sure what works/doesn't 1 Answer
Unable to map throttle and rudder joystick axes to game actions 0 Answers
What to change in standard input modules for joystick, keyboard, and mouse input? 0 Answers
Which axis to set in the InputManager? 0 Answers