限制角色在相机范围内
来源:互联网 发布:高级sql生成选项 编辑:程序博客网 时间:2024/06/04 00:21
private float screenEdgeHorizontal = 80f; //the distance between the player and the horizontal edge of the screen 80private float screenEdgeVertical = 18f; //the distance between the player and the vertical edge of the screen
//keep the player within camera viewvoid KeepPlayerInCameraView(){Vector2 playerPosScreen = Camera.main.WorldToScreenPoint(transform.position); if (playerPosScreen.x + screenEdgeHorizontal > Screen.width && (playerPosScreen.y - screenEdgeVertical < 0)){//右下transform.position = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width-screenEdgeHorizontal, screenEdgeVertical, transform.position.z - Camera.main.transform.position.z)); } else if(playerPosScreen.x + screenEdgeHorizontal > Screen.width){//右transform.position = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width-screenEdgeHorizontal, playerPosScreen.y, transform.position.z - Camera.main.transform.position.z));} else if(playerPosScreen.x - screenEdgeHorizontal < 0f && (playerPosScreen.y - screenEdgeVertical < 0)){//左下transform.position = Camera.main.ScreenToWorldPoint( new Vector3(screenEdgeHorizontal, screenEdgeVertical, transform.position.z - Camera.main.transform.position.z));} else if(playerPosScreen.x - screenEdgeHorizontal < 0f){//左transform.position = Camera.main.ScreenToWorldPoint( new Vector3(screenEdgeHorizontal, playerPosScreen.y, transform.position.z - Camera.main.transform.position.z));} else if(playerPosScreen.y - screenEdgeVertical < 0){//下transform.position = Camera.main.ScreenToWorldPoint(new Vector3(playerPosScreen.x, screenEdgeVertical, transform.position.z - Camera.main.transform.position.z));}}
阅读全文
0 0
- 限制角色在相机范围内
- 将鼠标指针限制在某一范围内
- unity 检测物体是否在相机视野范围内
- IOS 判断是否在限制范围内(个人)
- android:clipChildren,是否限制子View在其范围内
- 限制窗口在屏幕范围内移动(不能移到屏幕外)
- 百度地图图片叠加层切片工具:限制地图观察范围在一个矩形范围内
- ITWEEN 相机运动 角色特写
- Unity3d相机跟随角色移动
- AS3在范围内拖动
- 创建角色名如何在中英文混排的情况下精确限制长度
- [GEngine]相机角色中间物体透明(BetweenTransparent)
- Unity3D第三视觉角色相机控制
- unity 相机平滑跟随游戏角色
- 转载他人:角色移动和相机跟随
- javascript在限定范围内移动
- 在整个xml范围内查找
- WebView显示在控制范围内
- 抽象工厂模式-与-工厂方法模式区别
- Keras中神经网络可视化模块keras.utils.visualize_util 的安装
- Windows上Python3.6环境django部署到Apache服务器
- iOS Block 介绍
- 【机器学习中的数学】基函数与函数空间
- 限制角色在相机范围内
- leetcode26: Remove Duplicates from Sorted Array
- 九九乘法表
- svn执行上下文错误由于目标计算机积极拒绝无法连接
- 如何在EditText中固定图片
- Android支付宝支付开发流程
- 将Anaconda 的python2升级到python3
- 37 《这才是心理学》 -豆瓣评分9.0
- 【大话数据结构】字符串及模式匹配