How to have multiple conections from a buton?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Syl

Greets!

Here, got a buton wich should change to scenes once pressed from diferent collisionshapes . And it is corectly conected to the diferent collision shapes. Trouble is, it’s always the same scene changed, whatever my collisionshapes’s scripts tells it about their scenes locations… It always keep the last signaled…

Should a buton conect only to one script and object?

:bust_in_silhouette: Reply From: Merlin1846

Try this.

if buttonPressed(collisionshape):
    if collisionshape.name == "square":
        change_scene(exampleScene1)

    if collisionshape.name == "triangle":
        change_scene(exampleScene2)

    if collisionshape.name == "circle":
        change_scene(exampleScene3)

But please note that I don’t think I spelled everything right but that should in general be it. Also when you are attaching signales in the editor, that part that says

if buttonPressed(collisionshape):

should be automatically added to the script when the button’s signal is connected.

Thxs, but i got that:

func _on_Enter_gui_input(event):
		if event is InputEventMouseButton and event.pressed and event.button_index == 1:
				get_tree().change_scene("res://Scenes/Gipsy-camp.tscn")

on my collisionshape’s scripts… A click mouse for a button, but that works the same. :slight_smile:

Syl | 2020-02-10 15:51