Пример #1
0
    void Start()
    {
        for (int i = 0; i < planetsToSpawn; i++)
        {
            GameObject newOrbit = OrbiterPrefab;
            newOrbit.transform.position  = this.transform.position;
            newOrbit.transform.rotation *= Quaternion.AngleAxis(Random.Range(0f, 360f), Vector3.up);
            planetScript pS = newOrbit.GetComponent <planetScript>();
            pS.player          = player;
            pS.detectionRadius = detectRadius;
            pS.lookSpeed       = lookSpeed;

            pS.xIn        = Random.Range(MinDistance, MaxDistance);
            pS.zIn        = Random.Range(MinDistance, MaxDistance);
            pS.orbitAngle = Random.Range(0f, maxAngle);
            pS.orbitTime  = Random.Range(6f, 15f);

            //just to randomise the clockwise/anticlockwise orbits of planets
            float positive = Random.Range(0, 10);
            float negative = Random.Range(0, 10);
            if (negative < positive)
            {
                pS.orbitTime *= -1f;
            }
            Instantiate(newOrbit);
        }
    }
Пример #2
0
    // Start is called before the first frame update
    //quaternion.lookrotation might be your best bet to make the meteors point towards the planet
    void Start()
    {
        startPosition = this.transform.position;
        targetScript  = target.GetComponent <planetScript>();


        //Vector2 direction = ((Vector2)target.transform.position - startPosition);
        //Quaternion heading = Quaternion.LookRotation(direction);
        //transform.rotation = Quaternion.RotateTowards(transform.rotation, heading, 400 * Time.deltaTime);
    }