Untitled
unknown
plain_text
2 years ago
948 B
9
Indexable
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CoinMove : MonoBehaviour
{
Coin cs;
ObjectPooler op;
PickupManager pm;
private void Awake()
{
op = ObjectPooler.instance;
}
void Start()
{
cs = gameObject.GetComponent<Coin>();
pm = FindObjectOfType<PickupManager>();
}
void Update()
{
if (cs.canAttract)
{
Debug.Log("Magnet is active", this);
transform.position = Vector2.MoveTowards(transform.position, cs.playerTransform.position, cs.moveSpeed * Time.deltaTime);
}
}
private void OnTriggerEnter2D(Collider2D collision)
{
if(collision.gameObject.tag == "Player")
{
// cs.canAttract = false;
op.DeactivateGameObject(gameObject.tag, gameObject);
}
}
}
Editor is loading...
Leave a Comment