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;控制是否显示多出的部分(可灵活运用)
随机推荐
- Spring 注解驱动(一)基本使用规则
Spring 注解驱动(一)基本使用规则 Spring 系列目录(https://www.cnblogs.com/binarylei/p/10198698.html) 一.基本使用 @Configur ...
- String... to 可变参数的使用
public class testMail { public static void fun(int... x) { for(int i = 0;i < x.length;i++) { Syst ...
- Axure学习(一)
了解Axure目前的一些评价信息以及可以学习Axure的网址.
- ros 编程习惯
1.设置ros的info,warning,debug,error等编写的时候要思考,何时该使用,以及在开头要使用设置rosconsole的级别来对应输出,以方便调试. 2.在使用ros_info等的时 ...
- maven 介绍(zz )
Maven 编辑 目录 1简介 2特点 3常用命令 4推荐书籍 5Win7配置 6生命周期 1 1简介 Maven是基于项目对象模型(POM),可以通过一小段描述信息来管理项目的构 ...
- 13个开源GIS软件 你了解几个?
地理信息系统(Geographic Information System,GIS)软件依赖于覆盖整个地球的数据集.为处理大量的 GIS 数据及其格式,编程人员创建了若干开源库和 GIS 套件. GIS ...
- tomcat项目中配置数据库连接池
1. 在项目中新建context.xml文件,不要在tomcat服务器的目录中修改context.xml(会对整个服务器生效).. 在web项目的META-INF中存放context.xml 2. ...
- 前端之css操作2
一 伪类选择器 伪类选择器就是在查找的后面加上冒号和状态 hover:悬浮到上面就会变化一种状态 link:没有接触的状态 active:点击是触发的状态 visited:点击后的状态 <!DO ...
- idea运行项目时报Error:java无效的源发行版:1.8
如果你安装的是JDK1.7,而在file->project structure中设置的是language level是8的话,就会出现这个错误提示:无效的源发行版:8. 解决办法:将语言级别改为 ...
- ajax from 提交
$.ajax({ cache: true, type: "POST", url:aj ...