Exemplo n.º 1
0
    //spawnWaver.cs is used to create the ship tail
    //it spawns a 'tail' made of prefab 'segments'
    //each segment has a WaveMotion.cs script attached
    //As mentioned in WaveMotion.cs, each segments starts at a different point in its motion path
    //When being instantiated, the values for each segment variables used to create the motion is set
    //This includes its 'period' which allows for the wave motion
    //Each of the segments is added to an array of game objects

    void Start()
    {
        segmentsArray = new GameObject[segments];

        for (int i = 0; i < segments; i++)
        {
            GameObject newPiece = bodySegment;
            GameObject piece    = Instantiate(newPiece, this.transform);
            piece.gameObject.name    = "Segment" + (i + 1);
            pieceScript              = piece.GetComponent <WaveMotion>();
            pieceScript.period       = (0.25f * i) / segments;
            piece.transform.position = new Vector3(this.transform.position.x, this.transform.position.y, this.transform.position.z - (spacing * i));
            pieceScript.rate         = speed;
            pieceScript.height       = waveHeight;
            if (i < 1)
            {
                piece.transform.localScale = new Vector3((1f / 1) + (2f / segments), piece.transform.localScale.y, piece.transform.localScale.z);
            }
            else
            {
                piece.transform.localScale = new Vector3(1f / i, piece.transform.localScale.y, piece.transform.localScale.z);
            }

            segmentsArray[i] = piece;
        }
    }
Exemplo n.º 2
0
 // Use this for initialization
 void Start()
 {
     m_Controller = GetComponent <PlayerController> ();
     m_WaveMotion = GetComponent <WaveMotion> ();
 }