Guys, I'm newbie and I have a problem that I can not solve yet. Please see attached img to get understand my issue.
I have a Family of objects - different boxes. I need to find the box nearest to the ship, but I have to take into account only those boxes that are at the fixed distance to the player.
I can easily find the nearest box without taking into account the distance to the player by Pick nearest to target.X, target.Y. But there is a problem with linking it to the distance to the player.
Perhaps I need to make an array of boxes that are at the desired distance to the player and then run through this array to compare the distance from each box to the target to find the closest one?
How to implement this algorithm?
Hi
You can use distance() to get the boxes in your radius, then pick the nearest one to the ship.
http://www.sizzle-games.com/boxexample.c3p
I Have attached an example .C3P file
Just move the Player around (Arrow Keys)to try out the distance from players radius to the box, this is set at 200, but can be changed to anything.
Edit, added drop and drag to boxes and spaceship