+1 vote

Hello there.

I have a building placed on the map that, when you clic on it, the UI with it informatios show :

func _on_tower_input_event(viewport, event, shape_idx):
if (event is InputEventMouseButton && event.pressed):
    Globals.main_game_node.tower_ui(self) #Open the UI of the tower
    if event.position.y > 450:
        #TOP position
        get_node("/root/playing/ui/tower").rect_global_position.y = 100
        get_node("/root/playing/ui/tower").rect_global_position.y = 500

I also have a spell, which when i clic, detect enemies on the map and apply effects.
Problem is that when the spell is placed on top of the building with the cursor, the building's UI open as well.
I know I have to use unhandled input, but I can t figure out how to apply it here.
And finding examples online, so far hasn't been a real success...

This is the event input for the spell as well:

if spell_mode == true and build_mode == false:
    #add pixel verification
    var mouse_position = get_global_mouse_position()
    if mouse_position.y < 685 and mouse_position.y > 102 and mouse_position.x < 467 and mouse_position.x > 15:

        if event is InputEventMouseButton:
            var pos = event.position
            if event.pressed:
                #clic - nothing, we apply the spell on release.
                spell_1 = load("res://spells/spell_" + str(selected_spell) + "/spell.tscn")
                spell_instances = spell_1.instance()
                spell_instances.active = 1 #So that when we first instance it to get info for button it doesnt "start"
                spell_instances.global_position = mouse_position
                reset_spell_timer(timer_reset, spell_instances.spell_cd)

                #close spell UI

                #release click
                #instance the spell selected

anyone able to show me how to implement/fix this please ?
So that I can see/learn and apply to the rest of my UI elements ^^

Thank you very much in advance

Godot version 3+
in Engine by (184 points)

1 Answer

0 votes


by (184 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.