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;控制是否显示多出的部分(可灵活运用)
随机推荐
- 秒懂 this
一:全局执行 console.log(this); // Window 可以看出在全局作用域中 this 指向当前的全局对象 Window. 二:函数中执行 1.非严格模式中 function fun ...
- OneZero第三周第四次站立会议(2016.4.7)
1. 时间: 18:35--18:50 共计15分钟. 2. 成员: X 夏一鸣 * 组长 (博客:http://www.cnblogs.com/xiaym896/), G 郭又铭 (博客:http: ...
- ubuntu下使用fstab挂载硬盘时,属于root,如何把它改为属于一个用户的(如sgjm)
http://zhidao.baidu.com/link?url=xnakfVD16EtunTSt3wBm153DyqHnXN3FSPO1E_2SpVmM5bmEIwICLA0N6zN85_ioQ3f ...
- kbmmw ORM 对象定义语法简析
使用kbmmw 的ORM 一定先要了解ORM 的对象定义语法. 下面简单说一下 // kbmMW_Table - Define a table. 定义一个表 // Must be used on cl ...
- 2018.10.24 NOIP模拟 小 C 的数组(二分+dp)
传送门 考试自己yyyyyy的乱搞的没过大样例二分+dp二分+dp二分+dp过了606060把我自己都吓到了! 这么说来乱搞跟被卡常的正解比只少101010分? 那我考场不打其他暴力想正解血亏啊. 正 ...
- jquery 特效
http://demo.howtoexe.com/instagram-gravity-gallery/index.html
- Arbiter
from 2015-EDCAV-Problems encountered in various arbitration techniques used in NOC router-A survey ...
- acitvemq的jvm监控
在conf/activemq.xml启用jmx监控 即在broker后面添加useJmx="true"配置参数 <managementContext> <mana ...
- myeclipse cannot connect to vm
启动tomcat时,tomcat可以直接运行,而debug时弹出 解决方法:打开360安全卫士的功能大全找到修复网络(LSP)点击立即修复就可以使用debug
- wx.setStorageSync(KEY,DATA)
wx.setStorageSync 每个微信小程序都可以有自己的本地缓存,可以通过wx.setStorage(wx.setStorageSync).wx.getStorage(wx.getStorag ...