예제 #1
0
    }       // END OF UPDATE()

    public void OnTriggerEnter2D(Collider2D gameItem)
    {
        // if player is hit by laser then
        if (gameItem.tag == "Player")
        {
            HealthManger.Damage(damageValue);
        }
        // for sparks
        Instantiate(sparkObj, transform.position, transform.rotation);
        Destroy(gameObject);
    }
예제 #2
0
    public void OnTriggerEnter2D(Collider2D gameItem)
    {
        // if player hits me then
        if (gameItem.tag == "Player")
        {
            // decreasing the health of the player;
            HealthManger.Damage(damageValue);


            // code for knocking back the player
            player.knockbackCounter = player.knockbackDelay;

            // if player is knocked from the right side then
            if (gameItem.transform.position.x < transform.position.x)
            {
                player.rightKnock = true;
            }
            else
            {
                player.rightKnock = false;
            }
        }
    }