当前位置:网站首页>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:垂直方向上旋转的最小角度值
边栏推荐
- Hundreds of web page special effects can be used. Don't you come and have a look?
- VLAN experiment
- Redis transaction mechanism implementation process and principle, and use transaction mechanism to prevent inventory oversold
- Linear DP acwing 895 Longest ascending subsequence
- About asp Net MVC project in local vs running response time is too long to access, the solution!
- Mongodb redis differences
- JS7day(事件对象,事件流,事件捕获和冒泡,阻止事件流动,事件委托,学生信息表案例)
- Js8day (rolling event (scroll family), offset family, client family, carousel map case (to be done))
- 线性DP AcWing 896. 最长上升子序列 II
- . Net wechat message template push
猜你喜欢
![[200 opencv routines] 100 Adaptive local noise reduction filter](/img/89/9e9b667dd28cb25af005b6028ef26c.jpg)
[200 opencv routines] 100 Adaptive local noise reduction filter

阿里初面被两道编程题给干掉,再次内推终上岸(已拿电子offer)

JS10day(api 阶段性完结,正则表达式简介,自定义属性,过滤敏感词案例,注册模块验证案例)

js3day(数组操作,js冒泡排序,函数,调试窗口,作用域及作用域链,匿名函数,对象,Math对象)
![[error record] cannot open](/img/d3/0435ae698ad635be71729c7c047a22.jpg)
[error record] cannot open "XXX" because Apple cannot check whether it contains malware
![[opencv learning] [Canny edge detection]](/img/8b/37694ae2f0f13f829f3c033da0605e.jpg)
[opencv learning] [Canny edge detection]

Linear DP acwing 896 Longest ascending subsequence II

应用LNK306GN-TL 转换器、非隔离电源

Day4 operator, self increasing, self decreasing, logical operator, bit operation, binary conversion decimal, ternary operator, package mechanism, document comment

Ltc3307ahv meets EMI standard, step-down converter qca7005-al33 phy
随机推荐
线性DP AcWing 899. 编辑距离
哈希表 AcWing 840. 模拟散列表
. Net, C # basic knowledge
West digital decided to raise the price of flash memory products immediately after the factory was polluted by materials
NTMFS4C05NT1G N-CH 30V 11.9A MOS管,PDF
Oracle从入门到精通(第4版)
阿里发布的Redis开发文档,涵盖了所有的redis操作
Floyd AcWing 854. Floyd finds the shortest path
js 迭代器 生成器 异步代码处理 promise+生成器 -> await/async
Linear DP acwing 899 Edit distance
Use MySQL events to regularly perform post seven world line tasks
难忘阿里,4面技术5面HR附加笔试面,走的真艰难真心酸
Std:: vector batch import fast de duplication method
Mui WebView down refresh pull-up load implementation
Jerry's weather code table [chapter]
Win10 system OmniPeek wireless packet capturing network card driver failed to install due to digital signature problem solution
VIM super practical guide collection of this one is enough
JS8day(滚动事件(scroll家族),offset家族,client家族,轮播图案例(待做))
OLED screen driver based on stm32
8A 同步降压稳压器 TPS568230RJER_规格信息