43 lines
872 B
C#
43 lines
872 B
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
|
||
public class Player : MonoBehaviour
|
||
{
|
||
public float moveSpeed;//移动速度
|
||
public float rotateSpeed;//旋转角度
|
||
private float angleY;//左右看角度,绕Y轴转
|
||
private float angleX;//上下看角度,绕x轴转
|
||
void Start()
|
||
{
|
||
|
||
}
|
||
|
||
|
||
void Update()
|
||
{
|
||
PlayerMove(); LookAround();
|
||
}
|
||
|
||
private void PlayerMove()
|
||
{
|
||
|
||
}
|
||
|
||
private void LookAround()
|
||
{
|
||
float mouseX = Input.GetAxis("Mouse X");
|
||
|
||
float lookHAngleY = mouseX* rotateSpeed;
|
||
angleY=angleY+ lookHAngleY;
|
||
|
||
|
||
float mouseY =- Input.GetAxis("Mouse Y");
|
||
float lookVAngleX = mouseY * rotateSpeed;
|
||
angleX = Mathf.Clamp(angleX + lookVAngleX, -60, 60);
|
||
|
||
transform.eulerAngles = new Vector3(angleX, angleY, transform.eulerAngles.z);
|
||
}
|
||
|
||
}
|