コード例 #1
0
ファイル: Bullet.cs プロジェクト: GonzaVissDev/SnowBross
 private void OnCollisionEnter2D(Collision2D collision)
 {
     //Cuando toque con el enemigo.
     if (collision.gameObject.tag == "Ground")
     {
         Destroy(this.gameObject);
     }
     if (collision.gameObject.tag == "Enemy")
     {
         if (collision.gameObject.GetComponent <Enemy_Script>() != null)
         {
             Enemy_Script Hit = collision.gameObject.GetComponent <Enemy_Script>();
             Hit.SendMessage("Bullet_Hit", 1);
             Destroy(this.gameObject);
         }
     }
 }
コード例 #2
0
    private void OnCollisionStay2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "Enemy")
        {
            if (collision.gameObject.GetComponent <Enemy_Script>() != null)
            {
                Enemy_Script EnemyCollision = collision.gameObject.GetComponent <Enemy_Script>();
                if (EnemyCollision.E_State == Enemy_Script.EnemyState.SnowBall)
                {
                    Player_MoveSnowBall = true;

                    if (Input.GetKeyDown(KeyCode.C))
                    {
                        EnemyCollision.SendMessage("Impulse", transform.position.x);
                    }
                }
            }
        }
    }