using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class CharacterControl : MonoBehaviour { // 当前移动速度 private float currentSpeed = 0f; private float speedSmoothVelocity = 0f; // 用于存储速度平滑过渡的参考值 //移动的速度 public float moveSpeed=1f; //主摄像机,用于确定移动的方向 public Camera mainCamera; private Vector3 moveDirection = Vector3.zero; //角色rigidbody private Rigidbody body; //弹跳力 public float JumpAbility = 1f; //跳后的移动速度 public float JumpMoveSpeed = 1f; //角色动画控制器 private CharacterAin Characterain; //接收输入 float vertical; float horizontal; //垂直和水平输入值计算出一个方向向量 Vector3 dir; //判断是否在移动 private bool IsMoving = false; // 定义相机 FOV 相关变量 public float normalFOV = 60f; // 正常行走时的FOV public float sprintFOV = 120f; // 奔跑时的FOV public float fovChangeSpeed = 2f; // FOV改变的速 //跑步切换的时间 private float MoveTime = 0f; //走路的时间 public float walkTime; //跑的时间 public float runTime; //跑步时平滑切换fov private float targetFOV; private Button recubtn; // Start is called before the first frame update void Start() { recubtn = GameObject.Find("Canvas/Recuse").GetComponent