Untitled
unknown
plain_text
a year ago
846 B
4
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 (pm.canAttract) { transform.position = Vector2.MoveTowards(transform.position, cs.playerTransform.position, cs.moveSpeed * Time.deltaTime); } } private void OnTriggerEnter2D(Collider2D collision) { if(collision.gameObject.tag == "Player") { op.DeactivateGameObject(gameObject.tag, gameObject); } } }
Editor is loading...
Leave a Comment