This is a dropped object in the scene that appears at random after an enemy dies. This can be a hat, bandanna, ammo or a weapon. Drops are NOT synchronized objects. They exist solely on the player's instance they were instantiated in, and no other player will see it. Objects with the PlayerDrop component are created by GameDirector.RPCGiveDrop which is invoked by the master client.
Inheritance: MonoBehaviour
Example #1
0
 private void OnCollisionStay2D(Collision2D collision)
 {
     if (collision.gameObject.tag == "Drop" && collecting && !player.maxed)
     {
         PlayerDrop drop = GetComponent <PlayerDrop>();
         player.AddPoints(drop.dropCost);
         AudioManager.instance.Play("CollectFX");
         Destroy(collision.gameObject);
     }
 }
Example #2
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "Player")
        {
            PlayerDrop playerDrop = collision.gameObject.GetComponent <PlayerDrop>();


            PlayerStats player = collision.gameObject.GetComponent <PlayerStats>();
            player.hitted = true;

            if (player.points == 100)
            {
                playerDrop.DropIt();
            }
            Destroy(gameObject);
        }
    }