// Update the initialTarget of the tracking station private static void ApplyInitialTarget() { CelestialBody home = PSystemManager.Instance.localBodies.Find(b => b.isHomeWorld); ScaledMovement movement = home.scaledBody.GetComponentInChildren <ScaledMovement>(); PlanetariumCamera.fetch.initialTarget = movement; }
void Update() { if (Target == null) { return; } // The SpaceCenter scene doesn't load a full planetary system, or at least it messes with it // a lot. Instead of using the last value from flight there, we should just assume // the star is fully visible there, until someone comes up with a better solution if (HighLogic.LoadedScene == GameScenes.SPACECENTER) { IsOccluded = true; return; } Vector3 vertexPos = Body.scaledBody.transform.position + new Vector3( Vertex.x * Body.scaledBody.transform.localScale.x, Vertex.y * Body.scaledBody.transform.localScale.y, Vertex.z * Body.scaledBody.transform.localScale.z); Collider[] colliders = Physics.OverlapCapsule(Target.position, vertexPos, 1f, ModularFlightIntegrator.SunLayerMask); IsOccluded = !colliders.Any(c => { Debug.Log(c); ScaledMovement m = c.GetComponent <ScaledMovement>(); if (m == null) { return(false); } if (m.celestialBody == FlightGlobals.currentMainBody) { return(false); } if (m.celestialBody != Body) { return(true); } return(false); }); }