Faced with an issue that I cannot figure out for quite a long time.
I try to show a menu with some choices after the player hits the interact action near some specific object. Technically, the player model has a raycast2d and a function that detects a situation when the player hits an interact button near object, that has method called "on_interact".
I just completely don't understand how can I call an a UI and "deliver" it a control. It seems that I should create a condition in UI's unhandledinput that checks interact action and that the player stands near interactable object but I don't know how it can be implemented. Moreover, I am not sure the this way is a correct at all.
Unfortunately, most of what I've found either tells about interactions inside UI only or tells too superficially.
Here is some code for context. Here is a Player code of an interaction
func try_interact ():
rayCast.cast_to = facingDir * interactDist
On the other hand, a PopUp menu has a code like so
if not visible:
# Pause game
already_paused = get_tree().paused
get_tree().paused = true
# Reset the popup
selected_menu = 0
# Show popup
selected_menu = (selected_menu + 1) % 3;
if selected_menu > 0:
selected_menu = selected_menu - 1
selected_menu = 2
# the code of processing the input