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类挂到物体上。
这篇博客探讨了如何通过编程计算抛物线的轨迹。内容主要围绕在游戏或物理模拟中,如何将Main类应用到物体上,以实现抛物线运动的精确计算和展示。
2470

被折叠的 条评论
为什么被折叠?



