admin 管理员组文章数量: 1184232
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityStandardAssets.Characters.FirstPerson;
using UnityEngine.UI;
public class Tiao_jie : MonoBehaviour {
public Text textdemo;
public Text textdemo2;
//灵敏度
private float lingmin=2;
private bool smooth_demo;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.KeypadMinus))
{
lingmin -= 0.2f;
if (lingmin <0)
{
lingmin = 0.2f;
}
transform.GetComponent<FirstPersonController>().m_MouseLook.XSensitivity = lingmin;
transform.GetComponent<FirstPersonController>().m_MouseLook.YSensitivity = lingmin;
StartCoroutine(Ynahi());
}
if (Input.GetKeyDown(KeyCode.KeypadPlus))
{
lingmin += 0.2f;
if (lingmin > 2)
{
lingmin = 2;
}
transform.GetComponent<FirstPersonController>().m_MouseLook.XSensitivity = lingmin;
transform.GetComponent<FirstPersonController>().m_MouseLook.YSensitivity = lingmin;
StartCoroutine(Ynahi());
}
if (Input.GetMouseButtonDown(2))
{
if (smooth_demo == false)
{
transform.GetComponent<FirstPersonController>().m_MouseLook.smooth = false;
}
else
{
transform.GetComponent<FirstPersonController>().m_MouseLook.smooth = true;
}
smooth_demo = !smooth_demo;
print(transform.GetComponent<FirstPersonController>().m_MouseLook.smooth);
StartCoroutine(Ynahi());
}
textdemo.text=string.Format("灵敏度:{0}", lingmin);
textdemo2.text = string.Format("是否平滑:{0}", transform.GetComponent<FirstPersonController>().m_MouseLook.smooth);
}
IEnumerator Ynahi()
{
textdemo.gameObject.SetActive(true);
textdemo2.gameObject.SetActive(true);
yield return new WaitForSeconds(3);
textdemo.gameObject.SetActive(false);
textdemo2.gameObject.SetActive(false);
}
}
//调节视距
Camera.main.fieldOfView = Camera.main.fieldOfView -Input.GetAxis("Mouse ScrollWheel") * 20;
Camera.main.fieldOfView = Mathf.Clamp(Camera.main.fieldOfView, 10, 60);
if (Input.GetKeyDown(KeyCode.F1))
{
Camera.main.fieldOfView = fileviewdefault;
transform.GetComponent<MouseLook>().XSensitivity = 2;
transform.GetComponent<MouseLook>().YSensitivity = 2;
transform.GetComponent<MouseLook>().smoothTime = 20;
}版权声明:本文标题:从菜鸟到大师:Unity第一人称控制器灵敏度的调教艺术 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1773309049a3560475.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论