Treasure Magnet HELP!!

well i’ve made a bool (that i would like to when active) make all the coins caught within its radius to be pulled into the center of the character COIN COLLECTION IS NOT THE PROBLEM pulling the coins towards the character is the problem
public LayerMask pickups;
public GameObject PowUP;
public bool inside;
public Transform shieldTransform;
public float mRadius;

	void Update(){

		inside = Physics2D.OverlapCircle(shieldTransform.position, mRadius, pickups);
		if (!inside) {
			return;
		}
		if (inside) {

			}
	}

}

Rather than saying nothing is working, why not explain what things you have changed. Your code doesn't actually do anything.

Yeah. pulling the treasure items towards the character would just be a manner of transform.translating towards the player's transform.position (or any other method of moving stuff, depending on wether you use physics etc).

1 Answer

1

Try this for moving the coins towards the player.

Also depending on how many coins you have in your scene at once. You might find that calling Physics2D.OverlapCircle every frame is sort of expensive. Might be better to use a trigger.