Beispiel #1
0
    //Algorithm that allows htting a target
    private void hitTarget(Collider other)
    {
        //Creates small recoil when fighting enemies horizontally
        if (rotation == 0)
        {
            if (facingRight)
            {
                parentRB.AddForce(Vector3.left * KNOCKBACK_SELF);
            }
            else
            {
                parentRB.AddForce(Vector3.right * KNOCKBACK_SELF);
                rotation = 180;
            }
        }
        else if (rotation == 270 && other.tag == "Enemy" && !slashJumped)         //Allows pogo claw jumping
        {
            parentRB.velocity = Vector3.zero;
            parentRB.AddForce(Vector3.up * KNOCKBACK_SLASH_JUMP);
            slashJumped = true;
        }
        else if (rotation == 90 && (other.tag == "Enemy" || other.tag == "EnemyAttack"))
        {
            parentRB.velocity = Vector3.zero;
            parentRB.AddForce(Vector3.down * KNOCKBACK_SELF);
        }

        //Create damagePackage to send to enemy hit
        DamagePackage dmgPackage = new DamagePackage(damage);           //Creates damage package to broadcast

        dmgPackage.setOrientationalKnockback(rotation, KNOCKBACK_OTHER);

        if (other.tag == "Enemy" || other.tag == "EnemyAttack")
        {
            other.SendMessage("getDamage", dmgPackage);
        }
    }