关于贝塞尔曲线的讲解,比较清楚的
点击查看
。
两点求曲线,
点击查看
。
类似吃鸡手雷抛物线,
点击查看
。
简单的追踪弹,就是实时插值飞行道具的朝向(一定时间或者其他条件可以直接设置朝向)。
例如:
private void FrameRotateToQuaternion(Quaternion _targetRotate)
{
transform.rotation = Quaternion.Slerp(transform.rotation, _targetRotate, rotateSpeed * Time.smoothDeltaTime);
}
计算目标朝向:
public static Vector3 Normalized(Vector3 fromPostion, Vector3 toPostion)
{
return (toPostion - fromPostion).normalized;
}
//获取(fromPostion)点到(toPostion)的四元数方向
public static Quaternion Lookat(Vector3 _from, Vector3 _target)
{
Vector3 tempV3 = Normalized(_from, _target);
if (tempV3 != Vector3.zero)
return Quaternion.LookRotation(tempV3);
else
return Quaternion.identity;
}
移动方式:
transform.Translate(Vector3.forward * flySpeed * Time.deltaTime);
版权声明:本文为songhuanfei2017原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。