extends Node3D
var animacion_actual = "AGACHAPREPARA"
func _ready():
$AnimationPlayer.play(animacion_actual)
func _physics_process(_delta):
# NUEVO CÓDIGO: Salir del juego al presionar la tecla Escape
if Input.is_action_just_pressed("ui_cancel"):
get_tree().quit()
var alguna_tecla_pulsada = false
# Comprobamos si alguna de las acciones está siendo presionada
if Input.is_action_pressed("achazo") or \
Input.is_action_pressed("mouse_left") or \
Input.is_action_pressed("mouse_right") or \
Input.is_action_pressed("DESDEABAJOPUÑETASO") or \
Input.is_action_pressed("ANDAALANTECONW") or \
Input.is_action_pressed("ANDAATRASCONS") or \
Input.is_action_pressed("DESDEABAJOPUÑETASO") or \
Input.is_action_pressed("DESDEABAJOPUÑETASO") or \
Input.is_action_pressed("CORRECACA") or \
Input.is_action_pressed("ui_accept") or \
Input.is_action_pressed("PATADAMEDIA") or \
Input.is_action_pressed("DESDEABAJOPUÑETASO") or \
Input.is_action_pressed("ui_accept") or \
Input.is_action_pressed("A") or \
Input.is_action_pressed("D"):
alguna_tecla_pulsada = true
# Animación de ESPADAZO
if Input.is_action_pressed("achazo") or Input.is_action_pressed("mouse_left"):
if animacion_actual != "PUÑETAZO":
$AnimationPlayer.play("PUÑETAZO")
#$AnimationPlayer/AudioStreamPlayer3D.play("MakeHuman default skeleton|ESPADAZO")
animacion_actual = "PUÑETAZO"
# Animación de ATRABESAR
elif Input.is_action_pressed("mouse_right") or Input.is_action_pressed("DESDEABAJOPUÑETASO"):
if animacion_actual != "INSPECCIONA":
$AnimationPlayer.play("INSPECCIONA", 0.0)
animacion_actual = "INSPECCIONA"
# Animación de ANDAR
elif Input.is_action_pressed("ANDAALANTECONW") or Input.is_action_pressed("A") or Input.is_action_pressed("D"):
if animacion_actual != "CAMINA":
$AnimationPlayer.play("CAMINA")
animacion_actual = "CAMINA"
elif Input.is_action_pressed("ANDAATRASCONS") or Input.is_action_pressed("A") or Input.is_action_pressed("D"):
if animacion_actual != "SALTA":
$AnimationPlayer.play("SALTA")
animacion_actual = "SALTA"
elif Input.is_action_pressed("PUÑETAZO") or Input.is_action_pressed("A") or Input.is_action_pressed("D"):
if animacion_actual != "CAMINA":
$AnimationPlayer.play("CAMINA")
animacion_actual = "CAMINA"
elif Input.is_action_pressed("CORRECACA") or Input.is_action_pressed("E") or Input.is_action_pressed("E"):
if animacion_actual != "INSPECCIONA":
$AnimationPlayer.play("INSPECCIONA")
animacion_actual = "INSPECCIONA"
elif Input.is_action_pressed("ui_accept") or Input.is_action_pressed("E") or Input.is_action_pressed("E"):
if animacion_actual != "INSPECCIONA":
$AnimationPlayer.play("INSPECCIONA")
animacion_actual = "INSPECCIONA"
elif Input.is_action_pressed("PATADAMEDIA") or Input.is_action_pressed("R") or Input.is_action_pressed("R"):
if animacion_actual != "PUÑETAZO":
$AnimationPlayer.play("PUÑETAZO")
animacion_actual = "PUÑETAZO"
elif Input.is_action_pressed("ui_accept") or Input.is_action_pressed("A") or Input.is_action_pressed("D"):
if animacion_actual != "CAMINA":
$AnimationPlayer.play("CAMINA")
animacion_actual = "CAMINA"
elif Input.is_action_just_pressed("PUÑETAZO") or Input.is_action_pressed("A") or Input.is_action_pressed("D"):
if animacion_actual != "CAMINA":
$AnimationPlayer.play("CAMINA")
animacion_actual = "CAMINA"
# Si no se presiona ninguna tecla, volvemos a la animación de descanso
elif not alguna_tecla_pulsada:
if animacion_actual != "AGACHAPREPARA":
$AnimationPlayer.play("AGACHAPREPARA", 1.5)
animacion_actual = "AGACHAPREPARA"
elif Input.is_action_pressed("achazo") or Input.is_action_pressed("A") or Input.is_action_pressed("D"):
if animacion_actual != "CAMINA":
$AnimationPlayer.play("CAMINA")
animacion_actual = "CAMINA"
--------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
Explicacion: en mi juego la animacion del personaje habeces hace cambios bruscos al pasar de una animacion a otra, consulte con la IA como solucionarlo. en mi juego por ejemplo al disparar el personaje levanta el brazo y cuando termino el disparo lo vaja bruscamente casi al instante , queda muy mal nada natural.......en el trozo de texto del codigo de color amarillo un simple cambio de valor soluciono el problema ese "1,5" añadido a la linea.......hay que corregir de esta forma los cambios bruscos de una animacion hacia otra, ¡menuda herramienta la IA!.