Topic was automatically imported from the old Question2Answer platform.
Asked By
psear
I have a game in which there are various Position2D’s dotted around a map for various tasks. I need a way to identify, for example, the closest 5 to a given coordinate.
This would be done every physics frame, so a computationally cheap way of achieving this is important.
just give every position a static body with collision. nothing big just small, and the the coordinate should contain an area2d with collider of a circle. the radius should be a little big but not too big. just find bodies in the area and do your calculation based on them.
Making everything into a body may not be that cheap. But I just got a nice idea. Wouldn’t astar2D make it faster and cheaper ? It has method to identify closest not-disabled point to given coordinate. It would allow You to write a code to repeat 5 times find closest undisabled point and make it disabled. Do You know how astar works ?