当前位置: 首页 > news >正文

如何给网站开发挂网站添加什么东西才能和用户体验

如何给网站开发挂,网站添加什么东西才能和用户体验,手机网站开发工具6,网站建设的频道是什么物理模拟重力 斜抛运动计算 抛物线计算 一、介绍二、原理三、实现如下PhysicsUtil.cs 工具类Missile.cs 四、资源分享 一、介绍 模拟Unity原始重力系统进行重写#xff0c;可是实现发射到指定目标位置并能继续当前力进行自身的弹力与摩擦继续运动 二、原理 将Unity原始不受控… 物理模拟重力 斜抛运动计算 抛物线计算 一、介绍二、原理三、实现如下PhysicsUtil.cs 工具类Missile.cs 四、资源分享 一、介绍 模拟Unity原始重力系统进行重写可是实现发射到指定目标位置并能继续当前力进行自身的弹力与摩擦继续运动 二、原理 将Unity原始不受控制的物理系统使用一个模拟重力的方式进行斜抛等操作在其落地瞬间将模拟的重力还原给Unity的原始重力从而达到可任意抛物线移动的物理系统 三、实现如下 PhysicsUtil.cs 工具类 using UnityEngine;/// summary 物理计算工具 /// paraZhangYu 2018-05-10/para /// /summary public static class PhysicsUtil {/**findInitialVelocity* Finds the initial velocity of a projectile given the initial positions and some offsets* param Vector3 startPosition - the starting position of the projectile* param Vector3 finalPosition - the position that we want to hit* param float maxHeightOffset (default0.6f) - the amount we want to add to the height for short range shots. We need enough clearance so the* ball will be able to get over the rim before dropping into the target position* param float rangeOffset (default0.11f) - the amount to add to the range to increase the chances that the ball will go through the rim* return Vector3 - the initial velocity of the ball to make it hit the target under the current gravity force.* * Vector3 tt findInitialVelocity (gameObject.transform.position, target.transform.position);Rigidbody rigidbody gameObject.GetComponentRigidbody ();Debug.Log (tt);rigidbody.AddForce(tt*rigidbody.mass,ForceMode.Impulse);*/public static Vector3 GetParabolaInitVelocity(Vector3 from, Vector3 to, float gravity 9.8f, float heightOff 0.0f, float rangeOff 0.11f){// get our return value ready. Default to (0f, 0f, 0f)Vector3 newVel new Vector3();// Find the direction vector without the y-component/// /找到未经y分量的方向矢量//Vector3 direction new Vector3(to.x, 0f, to.z) - new Vector3(from.x, 0f, from.z);// Find the distance between the two points (without the y-component)//发现这两个点之间的距离不y分量//float range direction.magnitude;// Add a little bit to the range so that the ball is aiming at hitting the back of the rim.// Back of the rim shots have a better chance of going in.// This accounts for any rounding errors that might make a shot miss (when we dont want it to).range rangeOff;// Find unit direction of motion without the y componentVector3 unitDirection direction.normalized;// Find the max height// Start at a reasonable height above the hoop, so short range shots will have enough clearance to go in the basket// without hitting the front of the rim on the way up or down.float maxYPos to.y heightOff;// check if the range is far enough away where the shot may have flattened out enough to hit the front of the rim// if it has, switch the height to match a 45 degree launch angle//if (range / 2f maxYPos)// maxYPos range / 2f;if (maxYPos from.y)maxYPos from.y;// find the initial velocity in y direction/// /发现在y方向上的初始速度//float ft;ft -2.0f * gravity * (maxYPos - from.y);if (ft 0) ft 0f;newVel.y Mathf.Sqrt(ft);// find the total time by adding up the parts of the trajectory// time to reach the max//发现的总时间加起来的轨迹的各部分////时间达到最大//ft -2.0f * (maxYPos - from.y) / gravity;if (ft 0)ft 0f;float timeToMax Mathf.Sqrt(ft);// time to return to y-target//时间返回到y轴的目标//ft -2.0f * (maxYPos - to.y) / gravity;if (ft 0)ft 0f;float timeToTargetY Mathf.Sqrt(ft);// add them up to find the total flight time//把它们加起来找到的总飞行时间//float totalFlightTime;totalFlightTime timeToMax timeToTargetY;// find the magnitude of the initial velocity in the xz direction/// /查找的初始速度的大小在xz方向//float horizontalVelocityMagnitude range / totalFlightTime;// use the unit direction to find the x and z components of initial velocity//使用该单元的方向寻找初始速度的x和z分量//newVel.x horizontalVelocityMagnitude * unitDirection.x;newVel.z horizontalVelocityMagnitude * unitDirection.z;return newVel;}/// summary 计算抛物线物体在下一帧的位置 /summary/// param nameposition初始位置/param/// param namevelocity移动速度/param/// param namegravity重力加速度/param/// param nametime飞行时间/param/// returns/returnspublic static Vector3 GetParabolaNextPosition(Vector3 position, Vector3 velocity, float gravity, float time){velocity.y gravity * time;return position velocity * time;}}Missile.cs using UnityEngine;/// summary /// 抛物线导弹 /// para计算弹道和转向/para /// paraZhangYu 2019-02-27/para /// /summary public class Missile : MonoBehaviour {public Transform target; // 目标public float hight 16f; // 抛物线高度public float gravity -9.8f; // 重力加速度private Vector3 position; // 我的位置private Vector3 dest; // 目标位置private Vector3 velocity; // 运动速度private float time 0; // 运动时间private void Start(){dest target.position;position transform.position;velocity PhysicsUtil.GetParabolaInitVelocity(position, dest, gravity, hight, 0);transform.LookAt(PhysicsUtil.GetParabolaNextPosition(position, velocity, gravity, Time.deltaTime));}private void Update(){// 计算位移float deltaTime Time.deltaTime;position PhysicsUtil.GetParabolaNextPosition(position, velocity, gravity, deltaTime);transform.position position;time deltaTime;velocity.y gravity * deltaTime;// 计算转向transform.LookAt(PhysicsUtil.GetParabolaNextPosition(position, velocity, gravity, deltaTime));// 简单模拟一下碰撞检测if (position.y dest.y){if (Vector3.Distance(transform.position,target.position) 2) return;GetComponentRigidbody().useGravity true;GetComponentRigidbody().velocity velocity;enabled false;};}}四、资源分享 CSDN下载链接 在我的资源中搜索 PhysicsMissile
http://www.zqtcl.cn/news/416904/

相关文章:

  • 网站建设联系网站改备案信息吗
  • 建设一个看电影的网站唐山网址建站
  • 呼和浩特网站建设价格vs网站开发入门
  • 中国农业工程建设协会网站有专业做线切割配件的网站吗
  • 东莞建网站公司哪个好陕西手机网站建设公司
  • 网站系统里不能打印西安哪有学做淘宝网站
  • 哈尔滨建站模板大全天猫购买
  • 去后台更新一下网站百度最新版下载
  • 盐城网站开发教育建设网站
  • 目前网站开发有什么缺点广东品牌网站建设968
  • 东营做网站优化哪家好简单网站的制作
  • c可以做网站么网站为何不显示百度商桥对话框
  • 音乐网站用dw怎么做怎么做自己的网站教程
  • 网站换域名后需要多长时间才能收录恢复正常做文案公众号策划兼职网站
  • 丹阳做网站的公司重庆建设医院网站
  • 罗湖网站设计费用在线设计平台行业环境
  • 舟山市普陀区建设局网站淘宝怎样优化关键词
  • 网页上做ppt的网站好花西子网络营销案例分析
  • 网站设计说明书主要有什么成都企业网站seo
  • 免费素材下载网站网站建设进度时间表
  • 网站做关键词首页什么是网络营销?如何理解它的产生和把握它的特点?
  • centos做网站扬州市邗江区城乡建设局网站
  • 宁波网站建设模板制作企业做网站的作用
  • 南通网站快速收录禁止wordpress自动更新
  • 济南做网站最好的公司做一电影网站怎么赚钱吗
  • 中国城市建设网站宿州网站建设零聚思放心
  • 佛山网站免费制作struts2 做的网站
  • 做网站需要了解什么软件电商网站建设方案道客巴巴
  • 网站开发语言用什么好网站好坏怎么分析
  • 镇江制作网站的dw新建站点