当前位置:网站首页>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:垂直方向上旋转的最小角度值
边栏推荐
- Redis transaction mechanism implementation process and principle, and use transaction mechanism to prevent inventory oversold
- bellman-ford AcWing 853. Shortest path with side limit
- Typora+docsify quick start
- Linear DP acwing 895 Longest ascending subsequence
- West digital decided to raise the price of flash memory products immediately after the factory was polluted by materials
- Does C language srand need to reseed? Should srand be placed in the loop? Pseudo random function Rand
- The UVM Primer——Chapter2: A Conventional Testbench for the TinyALU
- C operator
- LTC3307AHV 符合EMI标准,降压转换器 QCA7005-AL33 PHY
- Use MySQL events to regularly perform post seven world line tasks
猜你喜欢
国内首款、完全自主、基于云架构的三维CAD平台——CrownCAD(皇冠CAD)
Rust search server, rust quick service finding tutorial
Domestic free data warehouse ETL dispatching automation operation and maintenance expert taskctl
难忘阿里,4面技术5面HR附加笔试面,走的真艰难真心酸
Heap acwing 838 Heap sort
C modifier
[opencv learning] [moving object detection]
JS6day(DOM结点的查找、增加、删除。实例化时间,时间戳,时间戳的案例,重绘和回流)
Redis sentinel mechanism and configuration
Linear DP acwing 896 Longest ascending subsequence II
随机推荐
Variable, "+" sign, data type
百款拿来就能用的网页特效,不来看看吗?
国内首款、完全自主、基于云架构的三维CAD平台——CrownCAD(皇冠CAD)
Day4 operator, self increasing, self decreasing, logical operator, bit operation, binary conversion decimal, ternary operator, package mechanism, document comment
Async/await asynchronous function
JDBC prevent SQL injection problems and solutions [preparedstatement]
Redis introduction, scenario and data type
Linear DP acwing 898 Number triangle
堆 AcWing 838. 堆排序
NTMFS4C05NT1G N-CH 30V 11.9A MOS管,PDF
Window10 upgrade encountered a big hole error code: 0xc000000e perfect solution
三面阿里,有惊无险成功拿到offer定级P7,只能说是真的难
Oracle从入门到精通(第4版)
Mobile layout (flow layout)
Hash table acwing 840 Simulated hash table
[opencv learning] [common image convolution kernel]
Js1day (input / output syntax, data type, data type conversion, VaR and let differences)
Get started REPORT | today, talk about the microservice architecture currently used by Tencent
Typora+docsify quick start
[opencv learning] [template matching]