Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        // Get a reference to the rigidbody
        rb = GetComponent <Rigidbody2D> ();

        // Get a reference to the planet
        planet = FindObjectOfType <test_Planet> ().GetComponent <test_Planet>();

        // Get a reference to the rocket booster
        booster = GetComponentInChildren <ParticleSystem>();

        // Start Off
        var emitter = booster.emission;

        emitter.enabled = false;
    }
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        // Get a reference to the planet
        planet = FindObjectOfType <test_Planet> ().GetComponent <test_Planet>();

        // Find out the starting radius
        radius = (planet.transform.position - transform.position).magnitude;

        // Get a reference to a rigid body
        rb = GetComponent <Rigidbody2D>();

        // Find the angle of the statlite to the planet
        float angle = Mathf.Atan2(transform.position.y, transform.position.x);

        // Find the direction of the tangential force based on the starting position ( Might not be required if we use rockets to accelerate the satalites up there)
        Vector2 forceDir = new Vector2(-transform.position.y / Mathf.Tan(90 * Mathf.Deg2Rad - angle), radius * Mathf.Sin(angle));

        // Add the initial force to make the satalite orbit
        rb.AddForce(forceDir.normalized * initialForce);
    }