位置: 编程技术 - 正文

摄像机各种效果(各种摄像机的介绍)

编辑:rootadmin
/// <summary>/// Mouse orbit./// This script use to control a main camera/// </summary>using UnityEngine;using System.Collections;public class MouseOrbit : MonoBehaviour {[HideInInspector]public GameObject target; //a target look at public float xSpeed; //speed pan xpublic float ySpeed; //speed pan ypublic float yMinLimit; //y min limitpublic float yMaxLimit; //y max limit public float scrollSpeed; //scroll speedpublic float zoomMin; //zoom minpublic float zoomMax; //zoom max//Private variableprivate float distance;private float distanceLerp;private Vector3 position; private bool isActivated; private float x;private float y;// private bool setupCamera; // Use this for initialization void Start () {//Warning when not found targetif(target == null){target = GameObject.FindGameObjectWithTag("Player");if(target == null){Debug.LogWarning("Don't found player tag please change player tag to Player");}} //Setup PosVector3 angles = transform.eulerAngles;x = angles.y;y = angles.x;//摄像机的视野范围 CalDistance(); } void LateUpdate () { ScrollMouse();RotateCamera(); }//Roate camera method//实现摄像机跟随和相机旋转效果void RotateCamera(){if (Input.GetMouseButtonDown(1)){ isActivated = true; } // if mouse button is let UP then stop rotating camera if (Input.GetMouseButtonUp(1)){isActivated = false;} if (target && isActivated) { y -= Input.GetAxis("Mouse Y") * ySpeed; x &#;= Input.GetAxis("Mouse X") * xSpeed; y = ClampAngle(y, yMinLimit, yMaxLimit); Quaternion rotation = Quaternion.Euler(y, x, 0);Vector3 calPos = new Vector3(0, 0, -distanceLerp); position = rotation * calPos &#; target.transform.position; transform.rotation = rotation; transform.position = position; } else{Quaternion rotation = Quaternion.Euler(y, x, 0);Vector3 calPos = new Vector3(0, 0, -distanceLerp); position = rotation * calPos &#; target.transform.position; transform.rotation = rotation; transform.position = position;}} //Calculate Distance Method//摄像机的视野范围 void CalDistance(){distance = zoomMax;distanceLerp = distance;Quaternion rotation = Quaternion.Euler(y, x, 0);Vector3 calPos = new Vector3(0, 0, -distanceLerp); position = rotation * calPos &#; target.transform.position; transform.rotation = rotation; transform.position = position;}//Scroll Mouse Methodvoid ScrollMouse(){distanceLerp = Mathf.Lerp(distanceLerp,distance,Time.deltaTime * 5);if (Input.GetAxis("Mouse ScrollWheel") != 0 && !GUI_Menu.instance.CheckHoverItemShop() && !GUI_Menu.instance.CheckHoverSkillWindow()) { // get the distance between camera and target distance = Vector3.Distance (transform.position , target.transform.position); distance = ScrollLimit(distance - Input.GetAxis("Mouse ScrollWheel")*scrollSpeed, zoomMin, zoomMax); }} //Scroll Limit Methodfloat ScrollLimit(float dist, float min, float max) { if (dist < min) dist= min; if (dist > max) dist= max; return dist; }//Clamp Angle Methodfloat ClampAngle(float angle,float min,float max){if(angle < -)angle &#;= ;if(angle > )angle -= ;return Mathf.Clamp(angle,min,max);}}

推荐整理分享摄像机各种效果(各种摄像机的介绍),希望有所帮助,仅作参考,欢迎阅读内容。

摄像机各种效果(各种摄像机的介绍)

文章相关热门搜索词:摄像机各种效果图,各种摄像机的介绍,摄像机各种效果图片,摄像机拍摄效果,摄像机各种效果图片,各种摄像机的介绍,摄像机各种效果对比,摄像机各种效果图,内容如对您有帮助,希望把文章链接给更多的朋友!

如何防范unity代码被偷! 解密无非就为了修改游戏功能数据、提取游戏资源、加入自己想加的广告等等加密就是保护游戏资源不被恶意修改关于UnityC#代码部分的加密,混淆,可

[置顶] 用Unity写了一个类似汤姆猫自动检测说话功能 简单的把脚本加到摄像机上就行下面是我写的脚本,有个问题因为是自动调用检测的调用录音unity调用有延时会出现一些延时小问题,可以参考我的代码

[置顶] Unity处理Hierarchy面板上的一些特殊的对象的特殊标识 孙广东.5.转载请注明出处:

本文链接地址:https://www.jiuchutong.com/biancheng/372847.html 转载请保留说明!

上一篇:Unity3D入门——GUI的Label控件(unity3d documentation)

下一篇:如何防范unity代码被偷!(unity如何避免碰撞穿透)

免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

鄂ICP备2023003026号

网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

友情链接: 武汉网站建设 电脑维修 湖南楚通运网络