using System. The Collections;
using System.Collections.Generic;
Using UnityEngine;
Public class MouseLook: MonoBehaviour {
//Use this for initialization
Public enum RotationAxes
{
MouseXAndY=0,
MouseX=1,
MouseY=2
}
Public RotationAxes axes=RotationAxes. MouseXAndY;
Public float sensitivityHor=9.0 f;
Public float ensitivityVert=9.0 f;
Public float minimumVert=45.0 f;
Public float maximumVert=45.0 f;
Private float _rotationX=0;
Private Vector3 eulerAngels;
Void the Start () {
If (GameObject. FindWithTag (" as ".) GetComponent())
{
GameObject. FindWithTag (" as ".) GetComponent(). FreezeRotation=true;
}
EulerAngels=transform. LocalEulerAngles;
}
Void the Update () {
If (axes==RotationAxes. MouseX)
{
The transform. The Rotate (0, Input. GetAxis (" Mouse X ") * sensitivityHor, 0).
}
Else if (axes==RotationAxes. MouseY)
{
_rotationX -=Input. GetAxis (Mouse "Y") * sensitivityHor;
_rotationX=Mathf Clamp (_rotationX minimumVert, maximumVert);
Float rotationY=transform. LocalEulerAngles. Y;
Transform. LocalEulerAngles=new Vector3 (eulerAngels. X, eulerAngels. J y, eulerAngels. Z + rotationY);
}
The else
{
_rotationX -=Input. GetAxis (Mouse "Y") * sensitivityHor;
_rotationX=Mathf Clamp (_rotationX minimumVert, maximumVert);
Float delta=Input. GetAxis (" Mouse X ") * sensitivityHor;
Float rotationY=transform. LocalEulerAngles. Y + delta;
The transform. LocalEulerAngles=new Vector3 (_rotationX, rotationY, 0);
}
}
}
Pictures of binding script joints
CodePudding user response:
Alone to write a follow the code of pig feet, camera position height lerp smooth move or something...CodePudding user response:
I try it on, the one who knows