0
Answered

Action > Object > Nearest with Tag: doesn't return Empty game objects

marjohloo 5 months ago in Game Creator updated by Marti (Lead Developer) 5 months ago 2

Try to get my player to reach for a nearest object and to do a bit of trickery I want to reach for an empty object with a tag, that then collides with a different object in the same place (but has a different tags). Basically I want my player to reach for lots of different things and so use empty objects for all of them with a shared tag, but then having reached they collide with a different object with different effects. I'm storing the nearest returned item in a variable which is then reached for in the next action.

Based upon my experiments I suspect only objects with colliders are returned by Action > Object > Nearest with Tag.

Unity version:
2018.4.22f
Game Creator version:
1.1.6
GOOD, I'M SATISFIED

OK I guess the naming threw me, being under "object nearest with tag" probably "object nearest with collider and tag" but I guess that is a bit unwieldy. I understand it is working as intended.

Satisfaction mark by marjohloo 5 months ago

You can see this in the video below. 4 targets all with the same tag, on mouse click the nearest with tag is saved to variable and then reach for is invoked, the left and right hands are independant. The green targets have mesh colliders, the blue has a sphere collidor, the red has no collider, the settings for the red target on on screen at the start of the video.

You can see the player reaches quite happily for the green/blue targets, but never reaches for the red even when obviously the closest.

Edit: link 

Answered

Correct. Operations that check distance use Unity's Physic engine to optimize the query. Otherwise we'd need to compute the distance for all objects, which could take a big performance hit.

We're experimenting using a spatial partitioning algorithm to avoid using colliders, but it's still very far away from being production ready. Meanwhile, the solution is to add a collider.