Example #1
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Player")
     {
         playerVida.takeDamage(cantidad);
         jugador.transform.position = inicial.posInicial;
     }
 }
Example #2
0
    private void OnTriggerStay2D(Collider2D other)
    {
        if (other.tag == "Player")
        {
            if (!isProyectile && enemyLife.dead)
            {
                return;
            }
            if (playerVida.invulnerable)
            {
                return;
            }
            playerVida.takeDamage(cantidad);
            //StartCoroutine(Pmoviendose.instance.Knockback(KnockBackDuration, KnockBackPower, this.transform));
            var player = other.GetComponent <Pmoviendose>();
            player.knockbackCount = player.knockbackLenght;
            player.knockbackUp    = player.knockback;
            if (other.transform.position.y > transform.position.y)
            {
                player.knockbackUp *= 1;
            }
            else if (other.transform.position.y < transform.position.y)
            {
                player.knockbackUp *= -1;
            }
            else
            {
                player.knockbackUp = playerrb.velocity.y;
            }

            if (other.transform.position.x < transform.position.x)
            {
                player.knockRight = true;
            }
            else
            {
                player.knockRight = false;
            }
        }
    }