当前位置:网站首页>Unity SKFramework框架(十八)、RoamCameraController 漫游视角相机控制脚本
Unity SKFramework框架(十八)、RoamCameraController 漫游视角相机控制脚本
2022-07-02 09:45:00 【CoderZ1010】
目录
一、简介
RoamCameraController是用于漫游视角的相机控制脚本,同时支持Input System Package(New)和Input Manager(Old)新、旧两种输入系统。

该工具已经上传至我的框架SKFramework中的开发工具箱,如图所示。


框架已经在Github开源,地址:https://github.com/136512892/SKFramework

二、功能
1.键盘控制移动
通过键盘W、S、A、D、E、Q按键分别实现向前、后、左、右、上、下方向的移动:

2.视角拉近拉远
通过鼠标滚轮的滚动实现视角的拉近或拉远,作用等同于W、S按键:

3.视角旋转
通过按住鼠标右键并进行拖动实现视角的旋转:

通过设置verticalLimitMax、verticalLimitMin来限制在垂直方向上的旋转角度,以防止相机”倒立“。

4.视角聚焦
通过调用Focus函数实现视角的聚焦:
/// <summary>
/// 聚焦
/// </summary>
/// <param name="position">目标位置</param>
/// <param name="rotation">目标旋转</param>
/// <param name="duration">时长</param>
public void Focus(Vector3 position, Vector3 rotation, float duration);
5.活动区域限制
通过启用IsRangeClamped来实现活动范围的限制:

通过设置xMinValue...zMaxValue调整活动范围,如图所示,绿色线条形成的区域即活动的范围,相机运动不会超出该区域:

三、核心变量

toggle:控制系统的开关
isRangeClamped:是否启用活动区域限制
xMinValue、xMaxValue:在x轴上的活动区域范围,当isRangeClamped为true时起作用
yMinValue、yMaxValue:在y轴上的活动区域范围,当isRangeClamped为true时起作用
zMinValue、zMaxValue:在z轴上的活动区域范围,当isRangeClamped为true时起作用
translateSpeed:移动的速度
boost:加速系数,当按下键盘左边的Shift键时会加速移动
positionLerpTime:坐标插值到目标值所需时长
rotationLerpTime:旋转插值到目标值所需时长
mouseMovementSensitivity:鼠标灵敏度
mouseScrollMoveSpeed:鼠标滚轮滚动时视角拉近拉远的速度
invertScrollDirection:是否反转鼠标滚轮滚动时视角拉近拉远的方向
invertY:是否反转垂直方向上旋转的方向
verticalLimitMax:垂直方向上旋转的最大角度值
verticalLimitMin:垂直方向上旋转的最小角度值
边栏推荐
- bellman-ford AcWing 853. 有边数限制的最短路
- 线性DP AcWing 899. 编辑距离
- spfa AcWing 851. spfa求最短路
- JDBC prevent SQL injection problems and solutions [preparedstatement]
- The redis development document released by Alibaba covers all redis operations
- 软件测试面试题-2022年大厂面试题合集
- The coloring method determines the bipartite graph acwing 860 Chromatic judgement bipartite graph
- Js7day (event object, event flow, event capture and bubble, prevent event flow, event delegation, student information table cases)
- Redis bloom filter
- The UVM Primer——Chapter2: A Conventional Testbench for the TinyALU
猜你喜欢

Rust search server, rust quick service finding tutorial

Browser storage scheme

Hash table acwing 841 String hash
![[opencv] [image gradient]](/img/37/1f366501e2b4e70ecee6365088167c.jpg)
[opencv] [image gradient]

Dijkstra AcWing 850. Dijkstra求最短路 II

C modifier

js2day(又是i++和++i,if语句,三元运算符,switch、while语句,for循环语句)

线性DP AcWing 902. 最短编辑距离

Win10 system OmniPeek wireless packet capturing network card driver failed to install due to digital signature problem solution

阿里初面被两道编程题给干掉,再次内推终上岸(已拿电子offer)
随机推荐
Efficiency comparison between ArrayList and LinkedList
Interesting interview questions
The coloring method determines the bipartite graph acwing 860 Chromatic judgement bipartite graph
3 A VTT端接 稳压器 NCP51200MNTXG资料
Js1day (syntaxe d'entrée / sortie, type de données, conversion de type de données, Var et let différenciés)
Get started REPORT | today, talk about the microservice architecture currently used by Tencent
Interview questions for software testing - a collection of interview questions for large factories in 2022
线性DP AcWing 896. 最长上升子序列 II
Sensor adxl335bcpz-rl7 3-axis accelerometer complies with rohs/weee
Mongodb redis differences
JDBC 预防sql注入问题与解决方法[PreparedStatement]
Use MySQL events to regularly perform post seven world line tasks
架构师必须了解的 5 种最佳软件架构模式
ASP. Net MVC default configuration, if any, jumps to the corresponding program in the specified area
Js5day (event monitoring, function assignment to variables, callback function, environment object this, select all, invert selection cases, tab column cases)
Ali on three sides, it's really difficult to successfully get the offer rated P7
Variable, "+" sign, data type
Mui WebView down refresh pull-up load implementation
C#修饰符
Ntmfs4c05nt1g N-ch 30V 11.9a MOS tube, pdf