public class GTool{
// 计算抛物线
static public Vector3 getPoint(Vector3 start,Vector3 end,float t, float hight){
Vector3 value = Vector3.Lerp (start, end,t); // x z 轴上的线性位移
value.y = Mathf.Lerp(0,hight,Mathf.Sin(t*Mathf.PI)); // y 轴上的sin 抛物线位移
return value;
}
}
public class Main : MonoBebavior{
public float time; // 时间 (0到1之间)
public float height; // 抛物线高度
void Update(){
target.position = GTool.getPoint(start, end, time, height);
}
}
直接将Main类挂到物体上。