- Home /
The question is answered, right answer was accepted
Identify all items within range C#
Hi, I'm learning Unity and trying to do my first project. I've got a problem with a rather simple mechanism I want to implement:
In a top-down 2D game I want the player to be able to fire a probe (by pressing a key) that would identify all items within its range. All it needs to do is to show the labels with the names of those items above them. I want the range to move with the player (he's not dropping the probe, but is carrying it). It should only work once though - when I press the key only what happens to be within the range is identified.
I almost did it by creating a script that spawns a child object of the player. I wanted this object to have a circle collider that would activate the labels of the objects, but the collider of a child only works on the parent collider it seems.
I'd be very grateful for any help.
Thanks! All the best!
Would this be helpful? http://docs.unity3d.com/ScriptReference/Physics2D.OverlapCircleAll.html
I think it would, if I knew how to use it to achieve this specific outcome. :)
Answer by Charlie_Goldstove · Jun 02, 2014 at 05:47 PM
Okay, so I've realized this question might have been too broad. Sorry. I've managed to build this feature using http://docs.unity3d.com/ScriptReference/Physics2D.OverlapCircleAll.html
Now I'm struggling with attaching the GUI.Label to an object, but there are questions like this already.
Thanks for the help DMG!