add unit animation locomotion value dampening

This commit is contained in:
2024-10-07 20:16:30 +10:00
parent a616b0f069
commit c357917e9e

View File

@@ -13,6 +13,8 @@ var wandering_timer: float = 0
var wandering_center: Vector3 = Vector3.ZERO var wandering_center: Vector3 = Vector3.ZERO
var spawn_pos: Vector3 var spawn_pos: Vector3
var locomotion_value: float = 0
@onready var nav_agent: NavigationAgent3D = $NavigationAgent3D @onready var nav_agent: NavigationAgent3D = $NavigationAgent3D
@onready var ui_origin: Node3D = $UiOrigin @onready var ui_origin: Node3D = $UiOrigin
@onready var animation_tree: AnimationTree = $AnimationTree @onready var animation_tree: AnimationTree = $AnimationTree
@@ -87,10 +89,12 @@ func _animate(delta: float) -> void:
) )
# look_at(global_position + velocity, Vector3.UP, true) # look_at(global_position + velocity, Vector3.UP, true)
animation_tree.set( locomotion_value = move_toward(
"parameters/locomotion/blend_position", locomotion_value,
velocity.length() / MOVE_SPEED, velocity.length() / MOVE_SPEED,
delta * 8
) )
animation_tree.set("parameters/locomotion/blend_position", locomotion_value)
func _wander(delta: float) -> void: func _wander(delta: float) -> void: