Player is able to move while dialog is running

Godot Version

4.2.2

Question

Hello, im using dialogic to manage my dialogue system in a top down rpg, i already managed to display dialogue if the player is in the area but now the problem is that the player is still capable of moving while the dialog is running and i dont want that, what can i do?

heres my player code

Blockquote
extends CharacterBody2D

var speed = 150
var run_speed = 230
var is_running = false

@onready var animation = $AnimatedSprite2D

var current_animation = “”

func _ready():
pass

func _unhandled_input(event):

# Movimiento
velocity.x = Input.get_axis("move_left", "move_right")
velocity.y = Input.get_axis("move_up", "move_down")	

# Animaciones cuando no se mueve
if Input.is_action_just_released("move_down"):
		play_animation("default_down")
elif Input.is_action_just_released("move_up"):
		play_animation("default_up")
elif Input.is_action_just_released("move_right"):
		play_animation("default_right")
elif Input.is_action_just_released("move_left"):
		play_animation("default_left")

func update_animation():
var new_animation = “”

if abs(velocity.x) > abs(velocity.y):
	if velocity.x > 0:
		new_animation = "walk_right"
	else:
		new_animation = "walk_left"
else:
	if velocity.y > 0:
		new_animation = "walk_down"
	else:
		new_animation = "walk_up"

if current_animation != new_animation:
	play_animation(new_animation)

func play_animation(anim_name):
if animation.animation != anim_name:
animation.play(anim_name)
current_animation = anim_name

func _physics_process(delta):

is_running = Input.is_action_pressed("ui_back")
var current_speed = speed
if is_running:
	current_speed = run_speed

if velocity != Vector2.ZERO:
	velocity = velocity.normalized() * current_speed
	move_and_slide()
	update_animation()

func player():
pass

and the interactable object:

Blockquote
extends Area2D

var player_in_area = false
var dialog_in_course = false
var player

func _input(event):
if player_in_area:
if Input.is_action_just_pressed(“ui_ok”):
if Dialogic.current_timeline == null:
run_dialogue(“prueba1”)

func run_dialogue(dialogue_string):
Dialogic.start(dialogue_string)

func _on_body_entered(body):
if body.has_method(“player”):
player_in_area = true

func _on_body_exited(body):
if body.has_method(“player”):
player_in_area = false

Blockquote

I believe dialogic has signals for dialog starting and ending, can you connect to those on your player’s _ready function to stop and start movement respectively?

how? @_@

I think it’s something like this, though I don’t use dialogic anymore.

func _ready() -> void:
    Dialogic.timeline_started.connect(set_physics_process.bind(false))
    Dialogic.timeline_started.connect(set_process_input.bind(false))

    Dialogic.timeline_ended.connect(set_physics_process.bind(true))
    Dialogic.timeline_ended.connect(set_process_input.bind(true))

You can disable the player’s _physics_process function from running by using set_physics_process(false), which is what this example does, though it needs to be bounded to work with the connection. Similarly set_process_input can disable the player’s _input function from running.

1 Like

it worked! but the character is still facing to other directions haha

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.