Exemple #1
0
    void Fire()
    {
        float   x   = Random.Range(this.bottom.position.x - transform.position.x, this.top.position.x - transform.position.x);
        float   y   = Random.Range(this.bottom.position.y - transform.position.y, this.top.position.y - transform.position.y);
        Vector3 dir = new Vector3(x, y, 0);

        dir = dir.normalized;
        Hitable popcorn = this.popcornPool.GetHitable();

        popcorn.transform.position = this.myTransform.position;
        popcorn.transform.rotation = Quaternion.Euler(0, 0, Random.Range(0, 360));
        popcorn.gameObject.SetActive(true);
        popcorn.Init(dir * this.power);
    }