public void SpawnTrail()
    {
        GameObject trailObject = (GameObject)Instantiate(ballTrailPrefab);

        if (allTrails[3])
        {
            Destroy(allTrails[3].gameObject);
        }
        for (int i = 3; i > 0; i--)
        {
            allTrails[i] = allTrails[i - 1];
        }
        BallTrail trail = trailObject.GetComponent <BallTrail>();

        allTrails[0] = trail;
        trail.SetAlpha(1);
        if (allTrails[1])
        {
            allTrails[1].isTracing = false;
            allTrails[1].SetAlpha(0.6f);
        }
        if (allTrails[2])
        {
            allTrails[2].isTracing = false;
            allTrails[2].SetAlpha(0.3f);
        }
        if (allTrails[3])
        {
            allTrails[3].isTracing = false;
            allTrails[3].SetAlpha(0.1f);
        }
    }
Esempio n. 2
0
    void Start()
    {
        State = BallState.Reset;

        initialPos = transform.position;

        rigidBody = GetComponent <Rigidbody2D>();

        Trail = GetComponent <BallTrail>();
    }