| | |
| | | |
| | | private void OnTriggerEnter2D(Collider2D collision) |
| | | { |
| | | // get <Damageable> object if collision object has it |
| | | Damageable damageable = collision.GetComponent<Damageable>(); |
| | | |
| | | // OnTrigger with <Damageable> |
| | | if (damageable) |
| | | { |
| | | // Pickup health if not at max HP |
| | | if (damageable.Heal(healthRestore)) |
| | | { |
| | | Destroy(gameObject); |
| | |
| | | |
| | | private void OnTriggerStay2D(Collider2D collision) |
| | | { |
| | | // pickup while inside collision |
| | | OnTriggerEnter2D(collision); |
| | | } |
| | | |
| | | private void Update() |
| | | { |
| | | // rotate pickup object |
| | | transform.eulerAngles += spinRotatationSpeed * Time.deltaTime; |
| | | } |
| | | } |