U3D关于抛物线的轨迹的做法
来源:互联网 发布:无影和黑武士数据对比 编辑:程序博客网 时间:2024/04/28 20:25
添加两个cube ,把这个脚本附在一个cube上面,把另外一个cube弄到脚本的target对象上,点击运行就可以了
using UnityEngine;using System.Collections;public class joi : MonoBehaviour {public GameObject target;public float speed = 10;private float distanceToTarget;private bool move = true;void Start (){distanceToTarget = Vector3.Distance (this.transform.position, target.transform.position);StartCoroutine (Shoot ());}IEnumerator Shoot (){while (move) {Vector3 targetPos = target.transform.position;this.transform.LookAt (targetPos);float angle = Mathf.Min (1, Vector3.Distance (this.transform.position, targetPos) / distanceToTarget) * 45;this.transform.rotation = this.transform.rotation * Quaternion.Euler (Mathf.Clamp (-angle, -42, 42), 0, 0);float currentDist = Vector3.Distance (this.transform.position, target.transform.position);print ("currentDist" + currentDist);if (currentDist < 0.5f)move = false;this.transform.Translate (Vector3.forward * Mathf.Min (speed * Time.deltaTime, currentDist));yield return null;}}}
0 0
- U3D关于抛物线的轨迹的做法
- 模拟抛物线的轨迹
- 控件抛物线轨迹的实现
- 小折腾:JavaScript与元素间的抛物线轨迹运动
- JavaScript与元素间的抛物线轨迹运动
- js实现小球抛物线轨迹运动的两种方式
- U3D——刀光轨迹插件的改进
- 关于U3D当中的Yield
- 当点C在抛物线上移动时,求点P的轨迹方程
- 关于手机游戏中的炮弹轨迹——抛物线
- matlab绘制抛物线轨迹
- 轨迹,你的轨迹
- 关于集合类的做法!
- 关于Blog日历的做法
- 关于Blog日历的做法
- 关于Blog日历的做法
- 关于网线的标准做法!
- 关于窗体透明的做法
- introduction to window batch
- 【cocos2d-x】重力感应----移动小球
- winform程序,如何控制USB摄像头的像素?
- iOS通过http post上传图片
- lua学习:把lua文本文件“编译”成二进制的文本
- U3D关于抛物线的轨迹的做法
- TextView中设置不同颜色字体
- ExtJS组件自适应浏览器大小改变
- Android进阶(三) 数据存储之SharedPreference
- 浅谈单片机应用程序架构
- D - 01背包
- C#读取二进制文件浅析
- XmlToJson转换
- Oracle Union Union All 使用方法