Esempio n. 1
0
    // === Attack ===
    void attack()
    {
        if (inp_attack)
        {
            int     dirOffset = 1 * (facingRight ? 1 : -1);
            Vector2 pos       = new Vector2(this.transform.position.x + dirOffset, this.transform.position.y);

            Blast blast = Instantiate(oAttack, pos, Quaternion.identity).GetComponent <Blast>();

            if (!facingRight)    // Flip shot to match player
            {
                Vector3 newScale = blast.GetComponent <Transform>().localScale;
                newScale.x *= -1;
                blast.GetComponent <Transform>().localScale = newScale;
            }
        }
    }