miepzerino
2023-12-15 ec464e48e1c68737a820f70e5d40a87818ce2175
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class Pickup : MonoBehaviour
{
    public int healthRestore = 20;
 
    public Vector3 spinRotatationSpeed = new Vector3(0, 180, 0);
 
 
 
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Damageable damageable = collision.GetComponent<Damageable>();
 
        if (damageable)
        {
            if (damageable.Heal(healthRestore))
            {
                Destroy(gameObject);
            }
        }
    }
 
    private void OnTriggerStay2D(Collider2D collision)
    {
        OnTriggerEnter2D(collision);
    }
 
    private void Update()
    {
        transform.eulerAngles += spinRotatationSpeed * Time.deltaTime;
    }
}