I was working on a project and when the textbox is reading, I set a code to make the player's vector = Vector2.ZERO as it is a 2d game. the trees and code is shown here:
full level tree:

level code:

textbox code:
func showTextbox():
start.text = "*"
container.show()
func displayText():
var nextText = textQueue.pop_front()
stateChange(state.reading)
label.percent_visible = 0.0
label.text = nextText
showTextbox()
tween.interpolate_property(label, 'percent_visible', 0.0, 1.0, len(nextText) * readRate,
Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
tween.start()
func _on_Tween_tween_completed(_object, _key):
end.text = 'v'
stateChange(state.finished)
func stateChange(nextState):
now = nextState
match now:
state.ready:
pass
state.reading:
if Input.is_action_just_pressed('ui_accept'):
label.percent_visible = 1.0
$Tween.stop_all()
end.text = 'v'
stateChange(state.finished)
state.finished:
if Input.is_action_just_pressed('ui_accept'):
hideTextbox()
stateChange(state.ready)
hideTextbox()
func _ready():
hideTextbox()
queueText("hello my name is rajesh")
queueText('i see that your computer has a virus')
queueText('can i fix it pretty please??? Of course i\'ll need your bank details to you know make the transaction and um totally not for anything else')
player code:
extends KinematicBody2D
onready var timer = get_node('Timer')
onready var anim = $AnimationTree
onready var player = $AnimationPlayer
onready var state = anim.get('parameters/playback')
const max_speed = 140
const sprint_speed = 80
onready var vector = Vector2.ZERO
func _physics_process(delta):
vector.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
vector.y = Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up")
vector = vector.normalized()
if Input.is_action_pressed("sprint"):
move_and_collide(vector * sprint_speed * delta)
if vector != Vector2.ZERO:
anim.set('parameters/idle/blend_position', vector)
anim.set('parameters/run/blend_position', vector)
state.travel('run')
else:
state.travel('idle')
move_and_collide(vector * max_speed * delta)
if you need any extra detail just ask and I will supply hopefully asap. Thanks in advance!
extra clip of footage: