Godot 4.4
I made a basic Input.is_key_just_pressed and Input.is_key_just_unpressed and the animations I set only trigger while walking with WASD. Is there a better line I can use so the animation plays how I wish? Thank you!
Video of Problem: https://youtu.be/62VbiCtqUVg
if Input.is_action_pressed("crouch"):
anim_tree.set("parameters/Crouch/blend_amount", velocity.length() / SPEED)
if Input.is_action_just_released("crouch"):
anim_tree.set("parameters/Standing_Base/blend_amount", velocity.length() / SPEED)
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var input_dir := Input.get_vector("left", "right", "forward", "backward")
var direction := (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
direction = direction.rotated(Vector3.UP, spring_arm_pivot.rotation.y)
if direction:
velocity.x = lerp(velocity.x, direction.x * SPEED, lerp_val)
velocity.z = lerp(velocity.z, direction.z * SPEED, lerp_val)
armature.rotation.y = lerp_angle(armature.rotation.y, atan2(-velocity.x, -velocity.z), lerp_val)
else:
velocity.x = lerp(velocity.x, 0.0, lerp_val)
velocity.z = lerp(velocity.z, 0.0, lerp_val)
anim_tree.set("parameters/Run/blend_amount", velocity.length() / SPEED) ```