To move both the track and the skybox in relation to the camera, perform the following steps:
1. In the
Skybox
class, add a new property to allow us to set the rotation while maintaining a valid angle as follows:#region Properties public float Rotation { get { return rotation; } set { rotation = MathHelper.WrapAngle(value); } } #endregion
2. Inside the
if
statement in theUpdate()
method of theMarsRunnerPlayScreen
class, just before the rover is updated, update the variable that controls the track position and rotate the skybox as follows:if (playerPosition < 2880) { playerPosition += 15 * elapsed; skybox.Rotation += 0.1f * elapsed; }
3. Execute the game.