我试图让子弹预测玩家的未来位置,使用子弹的速度和玩家的当前速度。
“move”向量3是玩家的当前速度
这似乎应该工作,但子弹射击的距离太远,太靠后,或者有时在更高速度下稍微偏离方向
Vector3 水平速度 = new Vector3(movement.move.x, 0, movement.move.z);
float 子弹行驶时间 = Vector3.Distance(transform.position, player.transform.position) / 子弹速度;
Vector3 预测位置偏移 = 水平速度 * 子弹行驶时间;
Vector3 预测位置 = player.transform.position + 预测位置偏移;
子弹行驶时间 = Vector3.Distance(transform.position, 预测位置) / 子弹速度;
预测位置 = player.transform.position + 水平速度 * 子弹行驶时间;
Vector3 射击方向 = 预测位置;
评论 (0)