To keep the sun at a constant distance from my ship, I’ve done a couple things.
First, the Star.cs object has a GameObject called PlayerObject attached to it with public scope. I then reference the player ship here. From there, I add a second public float called RelativeDistanceFromPlayer. This is how far I wish to keep the sun object from the ship at all times (the Z plane).
For right now I have set this at 5000.0f, which should push the sun 5000 away from the ship and toward the ship as the ship turns to it or away from it.
if (PlayerObject != null && RelativeDistanceFromPlayer > 0.0f)
//keep the Z axis the relative distance from the player
Vector3 sunPosition = this.transform.position;
sunPosition.Set (PlayerObject.transform.position.x, PlayerObject.transform.position.y, PlayerObject.transform.position.z – RelativeDistanceFromPlayer);
this.transform.position = sunPosition;
All that is left is to add a targeting panel now and Phase III is complete.