C# 移动及限制移动距离
public class PlaneMove : MonoBehaviour {
//h:水平方向的控制,v:前后方向的控制
float h,v;
//Speed:飞机的飞行速度
public float Speed;
// Use this for initialization
void Start () { }
// Update is called once per frame
void Update () {
//水平方向的值
h = Input.GetAxis("Horizontal");
//垂直方向的值
v = Input.GetAxis("Vertical");
//垂直方向每秒移动一米
transform.position +=-v * new Vector3(0,0,1f) * Speed * Time.deltaTime;
//水平方向每秒移动一米
transform.position +=-h * new Vector3(1f,0,0) * Speed * Time.deltaTime;
//限制坐标 x轴 -3.5~3.5,z轴-10~1
Vector3 pos = transform.position;
float x = pos.x;
float z = pos.z;
x = Mathf.Clamp(x, -3.5f, 3.5f);
z = Mathf.Clamp(z, -10f, 1f);
pos.Set(x, pos.y, z);
transform.position = pos;
}
}
C# 移动及限制移动距离的更多相关文章
- OJ题解记录计划
容错声明: ①题目选自https://acm.ecnu.edu.cn/,不再检查题目删改情况 ②所有代码仅代表个人AC提交,不保证解法无误 E0001 A+B Problem First AC: 2 ...
- iOS之计算上次日期距离现在多久, 如 xx 小时前、xx 分钟前等
/** * 计算上次日期距离现在多久 * * @param lastTime 上次日期(需要和格式对应) * @param format1 上次日期格式 * @para ...
- 挑子学习笔记:对数似然距离(Log-Likelihood Distance)
转载请标明出处:http://www.cnblogs.com/tiaozistudy/p/log-likelihood_distance.html 本文是“挑子”在学习对数似然距离过程中的笔记摘录,文 ...
- 字符串编辑距离(Levenshtein距离)算法
基本介绍 Levenshtein距离是一种计算两个字符串间的差异程度的字符串度量(string metric).我们可以认为Levenshtein距离就是从一个字符串修改到另一个字符串时,其中编辑单个 ...
- [LeetCode] Rearrange String k Distance Apart 按距离为k隔离重排字符串
Given a non-empty string str and an integer k, rearrange the string such that the same characters ar ...
- [LeetCode] Shortest Word Distance III 最短单词距离之三
This is a follow up of Shortest Word Distance. The only difference is now word1 could be the same as ...
- [LeetCode] Shortest Word Distance II 最短单词距离之二
This is a follow up of Shortest Word Distance. The only difference is now you are given the list of ...
- ReactNative 根据scrollView/listview滑动距离动态修改NavBar颜色
我们常见某些APP上滑的时候,NavBar颜色会从透明渐变为某种颜色 原理非常简单,根据scrollView的回调动态修改NavBar的透明度即可. 在RN中,尤其是ListView中这个回调不是很好 ...
- sql server2008根据经纬度计算两点之间的距离
--通过经纬度计算两点之间的距离 create FUNCTION [dbo].[fnGetDistanceNew] --LatBegin 开始经度 --LngBegin 开始维度 --29.49029 ...
- UIScrollView设置滑动的距离
设置好scrollView.width即是控制滑动的距离, scrollView.clipsToBounds = NO;控制是否显示多出的部分(可灵活运用)
随机推荐
- Eclipse快速生成覆盖方法、Getter、Setter的方法
点击鼠标右键 --> Source --> 直接使用快捷键 Alt+Shift+s
- SPring中quartz的配置(可以用实现邮件定时发送,任务定时执行,网站定时更新等)
http://www.cnblogs.com/kay/archive/2007/11/02/947372.html 邮件或任务多次发送或执行的问题: 1.<property name=" ...
- 开发apicloud模块遇到的几个梗
2017-06-04 原来模块中不能的R.id.xxx,只能用UZResourcesIDFinder.getResIdID("mo_minivr_framecontainer") ...
- js中的find(),filter(),has()的用法和区别
filter():操作当前元素集,删除不匹配的元素,得到一个新的集合 <ul> <li class="a">list item 1</li> & ...
- 编译https://github.com/CIR-KIT/steer_drive_ros时出现的问题
解决gazebo对应的protobuf版本问题: I've come across to the same problem. I'm using Ubuntu 16.04, ROS Kinetic a ...
- web.xml 详细介绍(zz)
web.xml 详细介绍 博客分类: CoreJava WebXMLServletJSPTomcat http://mianhuaman.iteye.com/blog/1105522 1.启动一个W ...
- MVVM Light 笔记
4.关于子视图, MVVMLight Using Two Views:http://www.codeproject.com/Articles/323187/MVVMLight-Using-Two-Vi ...
- 2016-2017-2 20155312 实验二《Java面向对象程序设计》实验报告
知识总结 伪代码 产品代码 Java编程时,程序员对类实现的测试叫单元测试. 测试用例是为某个特殊目标而编制的一组测试输入.执行条件以及预期结果,以便测试某个程序路径或核实是否满足某个特定需求. 先写 ...
- delphi 10 seattle 安卓服务开发(一)
从delphi 开始支持安卓的开发开始, 安卓service 开发一直都是delphier 绕不过去的坎, 以前也有开发service 的方法,但是都是手工处理启动文件,而且要修改很多东西,基本上成 ...
- Codeforces Round #514 (Div. 2) E. Split the Tree(倍增+贪心)
https://codeforces.com/contest/1059/problem/E 题意 给出一棵树,每个点都有一个权值,要求你找出最少条链,保证每个点都属于一条链,而且每条链不超过L个点 和 ...