In the code posted, I do not see where speed
is used, which is probably why its not doing anything. Instead, what I would recommend doing is adding a boolean that stops the movement and clears the velocity, as then you can stop the player entirely. Something like this for your player script:
extends KinematicBody2D
export (int) var speed = 600
var velocity = Vector2()
export (bool) var can_move = true
func get_input():
velocity = Vector2()
if Input.is_action_pressed('ui_right'):
velocity.x += 190
if Input.is_action_pressed("Sprint Activated"):
velocity.x +=230
if Input.is_action_pressed('ui_left'):
velocity.x -= 190
if Input.is_action_pressed("Sprint Activated"):
velocity.x -=230
if Input.is_action_pressed("Sprint Right"):
velocity.x += 190
if Input.is_action_pressed("Sprint Left"):
velocity.x -= 230
# warning-ignore:unused_argument
func _physics_process(delta):
get_input()
# only call move_and_slide if the player can move
if (can_move == true):
velocity = move_and_slide(velocity)
Then in your cut scene trigger script, you just set can_move
to true
and false
:
func _ready():
$AnimationForExampleAreaCutScene.connect("animation_finished", self, "on_cutscene_finished")
func _on_Area2D_area_entered(area):
$AnimationForExampleAreaCutScene.play("PieCutScene")
$KinematicBody2D.can_move = false
func on_cutscene_finished(animation_name):
$KinematicBody2D.can_move = true
$Area2D.queue_free()