Moon.MoveLaunch C# (CSharp) Method

MoveLaunch() public method

public MoveLaunch ( ) : void
return void
    void MoveLaunch()
    {
        if (launch.transform.position == moon.transform.position)
        {
            GameObject earth = GameObject.FindGameObjectWithTag("Earth");
            if (earth == null)
            {
                Debug.LogWarning("Earth is missing, can't safely check Launch position!");
                return;
            }

            if (colMoon == null)
            {
                Debug.LogWarning("Moon's collider is missing, can't safely check Launch position!");
                return;
            }

            //do main logic
            //no suitable default launch position was found, move to outward face of moon, away from earth
            Vector3 dir = (earth.transform.position - moon.transform.position).normalized;
            launch.position = moon.transform.position + new Vector3(dir.x * colMoon.radius, dir.y * colMoon.radius, moon.transform.position.z) * 2;
            Debug.Log("Moon's Launcher moved from " + Vector3.zero + " to " + launch.position);

        }
    }