Replies: 1 comment
-
Turns out is possible to achieve this for Node2D using Node.is_greater_than, as outlined in this forum post. Yay! As Mrcdk writes there, do e.g. var intersections = direct_space.intersect_point(query)
if intersections:
intersections.sort_custom(func(a, b):
var obj_a = a.collider
var obj_b = b.collider
return obj_a.is_greater_than(obj_b)
) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
In a game with 2D elements, it is a very common action to click something which is rendered "closest" or "topmost" to the user, in analogy with render order for CanvasItem.
Imagine multiple overlapping Area2Ds. Perhaps representing a deck of cards. We can raycast a point using intersect_point to get all the overlapping cards - but how to get the top card?
I feel the engine should make such a simple task trivial, yet I run into massive headaches. Do I really need to Z-index each and every 2D object? Why can't I get the current tree order of a CanvasItem? In short - I just want to click the thing I see on the screen.
On a related note for context, see disussion 8965, issue 1058 and a forum post I made on the topic.
Beta Was this translation helpful? Give feedback.
All reactions