炮弹怎么击发
日后再说o?
后面有底火啊
为您推荐:
其他类似问题
扫描下载二维码7676人阅读
Unity3d学习(15)
using UnityE
using System.C
public class MoveCurve : MonoBehaviour {
public GameObject t1;
//开始位置
public GameObject t2;
//结束位置
// Update is called once per frame
void Update () {
//两者中心点
Vector3 center = (t1.transform .position + t2.transform.position) * 0.5f;
center -= new Vector3(0, 1, 0);
Vector3 start = t1.transform.position -
Vector3 end = t2.transform.position -
//弧形插值
transform.position = Vector3.Slerp(start,end,Time.time);
transform.position +=
还有一种方法也可以实现,代码如下
using UnityE
using System.C
public class ProjectileTest : MonoBehaviour
public GameO
//要到达的目标
public float speed = 10;
private float distanceToT
//两者之间的距离
private bool move =
void Start()
//计算两者之间的距离
distanceToTarget = Vector3.Distance(this.transform.position, target.transform.position);
StartCoroutine(StartShoot());
IEnumerator StartShoot()
while (move)
Vector3 targetPos = target.transform.
//让始终它朝着目标
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);
if (currentDist & 0.5f)
this.transform.Translate(Vector3.forward * Mathf.Min(speed * Time.deltaTime, currentDist));
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:320802次
积分:3551
积分:3551
排名:第6568名
原创:27篇
转载:95篇
评论:170条
(2)(2)(1)(1)(1)(1)(1)(1)(1)(1)(2)(1)(1)(1)(1)(2)(1)(8)(74)(1)(5)(5)(1)(3)(1)(1)(3)