- Home /
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).
Answer by Jopan · Oct 09, 2014 at 09:31 PM
Try this for moving the coins towards the player.
http://docs.unity3d.com/ScriptReference/Vector3.MoveTowards.html
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.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How to make enemy slowly run to player 1 Answer
How to add play again or quit dialog 1 Answer
CS0029 convert type 1 Answer
Object reference not set to an instance of an object (Raycast) 1 Answer