0 votes

I've created a Player that can talk with some random npcs. When the player is facing the npc, the player's raycast detect the npc and if the player uses "uiaccept", the dialogue start.
When the dialogue is over (to skip further the text, the player uses "ui
accept"), the dialogue starts again because when the player uses "ui_accept" he's still facing the npc.

The player's script:

func _physics_process(delta):

func get_object_collided():
    if canMove:
        var target = $RayCast2D.get_collider()
        if target != null:
            if target.is_in_group("NPC"):
                if Input.is_action_just_pressed("ui_accept"):
                    emit_signal("startDialogue", target)

The Interface's script:

func input(event):
    if global.isTalking:
        if Input.is_action_just_pressed("ui_accept") and (dialogueState != dialogueLenght):
            dialogueState += 1

So, my question is: "how can I switch the inputs from the player to the Interface and viceversa?

Godot version 3.2.3
in Engine by (15 points)

1 Answer

+1 vote
Best answer

You can try using the _unhandled_input() function for the player. It will only be called on events that haven't been consumed by something else yet so just make sure that the GUI consumes the event. More info here.

by (7,190 points)
selected by
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.