29 lines
609 B
C#
29 lines
609 B
C#
using System;
|
|
using UnityEngine;
|
|
|
|
public class ItemPickup : MonoBehaviour
|
|
{
|
|
public bool inRange;
|
|
[Header("Movement")]
|
|
[SerializeField] private Rigidbody2D rb;
|
|
[SerializeField] private float speed;
|
|
|
|
private void FixedUpdate()
|
|
{
|
|
if (inRange)
|
|
{
|
|
rb.linearVelocity = (transform.position - AbilityManager.instance.player.transform.position).normalized * speed;
|
|
}
|
|
}
|
|
|
|
private void OnTriggerEnter2D(Collider2D other)
|
|
{
|
|
PickupEffects();
|
|
Destroy(gameObject);
|
|
}
|
|
|
|
protected virtual void PickupEffects()
|
|
{
|
|
|
|
}
|
|
}
|