summaryrefslogtreecommitdiff
path: root/WorldlineKeepers/Assets/Scripts/Items/Item_Coin.cs
blob: 1549646f4cbec0183c9eff49de985bf294b2e451 (plain)
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
using MH;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering.Universal;

public class Item_Coin : ItemBase
{

    protected override void Update()
    {
        base.Update();

        UnitBase hero = UnitManager.hero;

        Vector2 pos = transform.position;
        Vector2 target = hero.transform.position;

        if(Vector2.Distance(pos, target) <= 0.1f)
        {
            this.gameObject.SetActive(false);
            Destroy(this.gameObject);
            return;
        }

        Vector2 cur = Vector2.Lerp(pos, target, 0.01f);
        transform.position = cur.ToVector3();
    }

}