When SolarSystem is at position (0, 0), the sun is centered at our marker. When SolarSystem is at position (-5, 0), the earth is on the marker. In this way, we can recenter our view by switching between bodies in the center using the object's Transform position relative to the SolarSystem parent.
Let's write a script for this. We'll attach it as a component to GameController:
- In GameController, add Component | New Script and name it PlanetView.
Open the script and edit it as follows:
File: PlaneView.cs public class PlanetView : MonoBehaviour { public Transform solarSystem; public Transform planet; void Update () { Vector3 position = solarSystem.localPosition; if (planet != null) { // move solar system so planet is in the ...