add: smooth move
This commit is contained in:
@ -7,22 +7,29 @@ const LERP_VELOCITY: float = 0.15
|
||||
@export var _character: CharacterBody3D = null
|
||||
@export var animation_player: AnimationPlayer = null
|
||||
|
||||
func animate(_velocity: Vector3) -> void:
|
||||
func animate(velocity: Vector3) -> void:
|
||||
if not _character.is_on_floor():
|
||||
if _velocity.y < 0:
|
||||
if velocity.y < 0:
|
||||
animation_player.play("fall")
|
||||
else:
|
||||
animation_player.play("up")
|
||||
return
|
||||
|
||||
if _velocity.length() > 0.1: # Если есть движение
|
||||
# Используем _has_input вместо проверки длины скорости
|
||||
if _character._has_input:
|
||||
if _character.is_running():
|
||||
animation_player.play("run") # Спринт
|
||||
animation_player.play("run")
|
||||
else:
|
||||
animation_player.play("walk") # Обычная ходьба
|
||||
animation_player.play("walk")
|
||||
return
|
||||
|
||||
animation_player.play("idle") # Бездействие
|
||||
# Плавное переключение на idle при инерции
|
||||
if velocity.length() > 0.5: # Небольшой порог для плавного перехода
|
||||
var current_anim = animation_player.current_animation
|
||||
if current_anim != "walk" and current_anim != "run":
|
||||
animation_player.play("walk", 0.1) # Плавный переход с blend_time 0.1 сек
|
||||
else:
|
||||
animation_player.play("idle", 0.2) # Плавный переход на idle
|
||||
|
||||
@rpc("any_peer", "reliable")
|
||||
func sync_player_rotation(rotation_y: float) -> void:
|
||||
|
Reference in New Issue
Block a user