我试图让我的飞船实体要么看向他们正在移动的方向,要么看向他们正在绕行的目标。在这一点上,我会对任何一个结果感到满意。不幸的是,尽管我对如何实现这一点进行了所有谷歌研究,但我似乎对底层数学的理解还不够。
这是我目前在我的 RotateSystem 中拥有的
public void Execute(ref Translation shipPosition, ref Ship ship, ref Rotation rotation)
{
ship.Theta += .0075f;
float3 delta = new float3(
ship.Radius * Mathf.Sin(ship.Theta) * Mathf.Cos(ship.Phi),
ship.Radius * Mathf.Cos(ship.Theta),
ship.Radius * Mathf.Sin(ship.Theta) * Mathf.Sin(ship.Phi));
rotation.Value = Quaternion.Slerp(rotation.Value,
Quaternion.LookRotation(ship.OrbitTarget + delta-shipPosition.Value),0.5f);
shipPosition.Value = ship.OrbitTarget + delta;
}