AnimationPlayer delay

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By newgodot_user
onready var animator = $KayKit_AnimatedCharacter_v12/AnimationPlayer
onready var camera_pivot = $camerapivot
onready var camera = $camerapivot/cameraboom/Camera

func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)

func _process(delta):
if Input.is_action_just_pressed("ui_cancel"):
	Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)

func _input(event):
if event is InputEventMouseMotion:
	rotation_degrees.y -= event.relative.x * mouse_sensitivity
	camera_pivot.rotation_degrees.x -= event.relative.y * mouse_sensitivity
	camera_pivot.rotation_degrees.x = clamp(camera_pivot.rotation_degrees.x, min_pitch, max_pitch)

func _physics_process(delta):
direction = Vector3()
if Input.is_action_pressed("forward"):
	forward = true
	direction.z = 1
	define_direction = true
	# walking animation control block.
	if not jump and not fall and not sprint:
		animator.play("Walk", 0.2)
else:
	forward = false
	# default pose.
	if not jump and not fall and not backward:
		animator.play("Idle", 0.3) 
		# previous animation/s will be blend to "Default" for 0.3 sec.
if Input.is_action_pressed("backward"):
	backward = true
	direction.z = -1
	define_direction = false
	# walking backwards.
	if not jump and not fall and not sprint:
		animator.play_backwards("Walk")
else:
	backward = false
if Input.is_action_pressed("sprint"):
	if forward and not jump and not fall:
		sprint = true
		boost = 1.4
		animator.play("Run", 0.3)
else:
	sprint = false
	boost = 1

direction = direction.normalized() 
direction *= speed * boost

# rotates the direction of movement depending on the rotation.
# easier, body moves where it is directed/faced.
direction = direction.rotated(Vector3(0, 1, 0), rotation.y)

velocity.x = direction.x
velocity.z = direction.z
velocity.y += gravity * delta

velocity = move_and_slide(velocity, Vector3.UP)

# if all boolean values are false, the body is falling.
if is_on_floor() and jump:
	jump = false
	gravity = -15

if is_on_floor() and Input.is_action_pressed("jump"):
	velocity.y = 10
	gravity = -20
	animator.play("Jump")
	jump = true

When I initially press any key (with an animation attached to it) there is a slight delay when transitioning from the idle animation. Any ideas on how to remove the delay?

SOLVED. Just needed to change the blend.

newgodot_user | 2022-06-27 05:30