当前位置:网站首页>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:垂直方向上旋转的最小角度值
边栏推荐
- [opencv learning] [image filtering]
- Js3day (array operation, JS bubble sort, function, debug window, scope and scope chain, anonymous function, object, Math object)
- Ali on three sides, it's really difficult to successfully get the offer rated P7
- Day4 operator, self increasing, self decreasing, logical operator, bit operation, binary conversion decimal, ternary operator, package mechanism, document comment
- 哈希表 AcWing 841. 字符串哈希
- About the loading of layer web spring layer components, the position of the layer is centered
- Floyd AcWing 854. Floyd finds the shortest path
- [200 opencv routines] 100 Adaptive local noise reduction filter
- Package management tools
- 移动式布局(流式布局)
猜你喜欢

堆 AcWing 838. 堆排序
![[opencv learning] [image histogram and equalization]](/img/e7/b8dc55a9febf2b2949fce3a7ac21f9.jpg)
[opencv learning] [image histogram and equalization]

bellman-ford AcWing 853. Shortest path with side limit

The coloring method determines the bipartite graph acwing 860 Chromatic judgement bipartite graph

Ntmfs4c05nt1g N-ch 30V 11.9a MOS tube, pdf

bellman-ford AcWing 853. 有边数限制的最短路

Hash table acwing 841 String hash

Linear DP acwing 896 Longest ascending subsequence II

spfa AcWing 852. spfa判断负环

Js7day (event object, event flow, event capture and bubble, prevent event flow, event delegation, student information table cases)
随机推荐
bellman-ford AcWing 853. 有边数限制的最短路
8 examples of using date commands
Oracle从入门到精通(第4版)
js4day(DOM开始:获取DOM元素内容,修改元素样式,修改表单元素属性,setInterval定时器,轮播图案例)
Interval DP acwing 282 Stone merging
Post order traversal sequence of 24 binary search tree of sword finger offer
Execute any method of any class through reflection
Tencent three sides: in the process of writing files, the process crashes, and will the file data be lost?
js3day(数组操作,js冒泡排序,函数,调试窗口,作用域及作用域链,匿名函数,对象,Math对象)
Jerry's weather code table [chapter]
8A 同步降压稳压器 TPS568230RJER_规格信息
Direct control PTZ PTZ PTZ PTZ camera debugging (c)
百款拿来就能用的网页特效,不来看看吗?
堆 AcWing 839. 模拟堆
3 A VTT端接 稳压器 NCP51200MNTXG资料
. Net wechat message template push
The redis development document released by Alibaba covers all redis operations
Should I have a separate interface assembly- Should I have a separate assembly for interfaces?
通过反射执行任意类的任意方法
线性DP AcWing 898. 数字三角形