add animations

This commit is contained in:
2026-04-23 11:23:43 +03:00
parent c7f0d9e176
commit bec9389bb8
4 changed files with 101 additions and 8 deletions
+9 -7
View File
@@ -26,6 +26,7 @@ var _is_aiming: bool = false
@onready var mesh_node: MeshInstance3D = $player_man
@onready var indicator_node: MeshInstance3D = $KickIndicator
@onready var anim_player: AnimationPlayer = $AnimationPlayer2
var player_mat: StandardMaterial3D
var indicator_mat: StandardMaterial3D
@@ -136,6 +137,7 @@ func _handle_iframes(delta: float) -> void:
func _do_kick() -> void:
kick_timer = kick_cooldown
_play_kick_blend()
var forward := -global_transform.basis.z
forward.y = 0.0
forward = forward.normalized() if forward.length() > 0.01 else Vector3(0.0, 0.0, -1.0)
@@ -201,6 +203,11 @@ func set_aim_direction(yaw_rad: float) -> void:
_aim_yaw = yaw_rad
_is_aiming = true
func _play_kick_blend() -> void:
var tw := create_tween()
tw.tween_method(func(v: float): mesh_node.set_blend_shape_value(0, v), 0.0, 1.0, 0.12)
tw.tween_method(func(v: float): mesh_node.set_blend_shape_value(0, v), 1.0, 0.0, 0.38)
func _squish_effect() -> void:
var tw := create_tween()
tw.tween_property(mesh_node, "scale", Vector3(1.3, 0.55, 1.3), 0.07)
@@ -212,18 +219,13 @@ func receive_kick(direction: Vector3, force: float) -> void:
velocity.x = direction.x * force
velocity.z = direction.z * force
invincible_timer = IFRAMES_DURATION * 0.5
_squish_effect()
func take_damage(amount: int) -> void:
if not is_alive or invincible_timer > 0.0:
return
invincible_timer = IFRAMES_DURATION
#health = max(0, health - amount)
#emit_signal("health_changed", health, max_health)
#var tw := create_tween()
#tw.tween_property(player_mat, "albedo_color", Color.RED, 0.08)
#tw.tween_property(player_mat, "albedo_color", BASE_COLOR, 0.25)
#if health <= 0:
#_die()
_squish_effect()
func heal(amount: int) -> void:
if not is_alive: