> For the complete documentation index, see [llms.txt](https://kdoore.gitbook.io/cs2335/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kdoore.gitbook.io/cs2335/f20_bkup_v2/project1-enhancements/pickup-selfdestruct.md).

# PickUp - SelfDestruct

```java
public enum PickupType
{
    crate, crystal, rock, heart                 //add as needed
}

[DisallowMultipleComponent] //only one of these scripts allowed on a gameObject
public class PickUp : MonoBehaviour {


   [SerializeField]  //allows modification in inspector 
   private int value;

    //read-only property
    public int Value
    {
        get { return value; }
    }

    public PickupType type; //what is the PickupType of this object

    private void Start() //this will cause pickups to self-destruct after random range of seconds
    {
        Invoke("DestroyMe", Random.Range(3, 7));
    }

    public void DestroyMe()
    {
        Destroy(gameObject);
    }

}
```
