bazar_alea/client/player/AnimationTree.gd

110 lines
5.1 KiB
GDScript

extends AnimationTree
class_name AnimBlend
@export var movement_script : CharacterMovementComponent
func _physics_process(_delta):
if !movement_script:
return
#Set Animation State
match movement_script.movement_state:
Global.MOVEMENT_STATE.NONE:
pass
Global.MOVEMENT_STATE.GROUNDED: # Sol
set("parameters/InAir/blend_amount" , 0.0)
#set("parameters/TimeSeek/seek_request", 0.0)
#set("parameters/Transition/transition_request","Idle")
Global.MOVEMENT_STATE.IN_AIR: # Air
set("parameters/InAir/blend_amount" , 1.0)
#set("parameters/InAir/transition_request","Failling")
Global.MOVEMENT_STATE.MANTLING: # couverture
pass
Global.MOVEMENT_STATE.RAGDOLL:
pass
if !movement_script.input_is_moving:
set("parameters/Transition/transition_request","Idle")
Global.msg_info("Idle", [])
elif movement_script.gait == Global.GAIT.WALKING and movement_script.input_is_moving:
set("parameters/Transition/transition_request","WalkForward")
Global.msg_info("Walk", [])
#set("parameters/Transition/transition_request","Idle")
#set("parameters/InAir/blend_amount" , 0.5)
func _physics_process__old(_delta):
if !movement_script:
return
#Set Animation State
match movement_script.movement_state:
Global.MOVEMENT_STATE.NONE:
pass
Global.MOVEMENT_STATE.GROUNDED: # Sol
set("parameters/InAir/blend_amount" , 0.0)
#set("parameters/Transition/transition_request","Idle")
Global.MOVEMENT_STATE.IN_AIR: # Air
set("parameters/InAir/blend_amount" , 1.0)
#set("parameters/InAir/transition_request","Failling")
Global.MOVEMENT_STATE.MANTLING: # couverture
pass
Global.MOVEMENT_STATE.RAGDOLL:
pass
#standing
if !movement_script.input_is_moving:
set("parameters/Transition/transition_request","Idle")
#set("parameters/VelocityDirection/Standing/transition_request","Idle")
#set("parameters/VelocityDirection/crouching/transition_request","Idle")
if movement_script.gait == Global.GAIT.WALKING and movement_script.input_is_moving:
set("parameters/Transition/transition_request","WalkForward")
#set("parameters/VelocityDirection/Standing/transition_request","Walk")
#set("parameters/VelocityDirection/crouching/transition_request","Walk")
if movement_script.gait == Global.GAIT.RUNNING and movement_script.input_is_moving:
set("parameters/Transition/transition_request","JogForward")
#set("parameters/VelocityDirection/Standing/transition_request","Jog")
if movement_script.gait == Global.GAIT.SPRINTING and movement_script.input_is_moving:
set("parameters/Transition/transition_request","Run")
#set("parameters/Execution/transition_request","Run")
#Couch/stand switch
match movement_script.stance:
Global.STANCE.STANDING:
set("parameters/Transition/transition_request","stand")
#set("parameters/VelocityDirection/crouch/transition_request" , "stand")
Global.STANCE.CROUCHING:
set("parameters/Transition/transition_request","crouch")
#set("parameters/VelocityDirection/crouch/transition_request" , "crouch")
if movement_script.rotation_mode == Global.ROTATION_MODE.LOOKING_DIRECTION or \
movement_script.rotation_mode == Global.ROTATION_MODE.AIMING:
if movement_script.animation_is_moving_backward_relative_to_camera == false:
set("parameters/Transition/transition_request","WalkForward")
#set("parameters/VelocityDirection/WalkFB/transition_request","Forward")
#set("parameters/VelocityDirection/JogFB/transition_request","Forward")
else:
set("parameters/Transition/transition_request","Backward")
#set("parameters/VelocityDirection/WalkFB/transition_request","Backward")
#set("parameters/VelocityDirection/JogFB/transition_request","Backward")
else:
set("parameters/Transition/transition_request","WalkForward")
#set("parameters/VelocityDirection/WalkFB/transition_request","Forward")
#set("parameters/VelocityDirection/JogFB/transition_request","Forward")
#On Stopped
if !(Input.is_action_pressed("ui_up") || Input.is_action_pressed("ui_down") || Input.is_action_pressed("ui_right") || Input.is_action_pressed("ui_left")) and (Input.is_action_just_released("ui_right") || Input.is_action_just_released("ui_down") || Input.is_action_just_released("ui_left") || Input.is_action_just_released("ui_up")):
var seek_time = get_node(anim_player).get_animation(tree_root.get_node("StopAnim").animation).length - movement_script.pose_warping_instance.CalculateStopTime((movement_script.actual_velocity * Vector3(1.0,0.0,1.0)),movement_script.deacceleration * movement_script.input_direction)
set("parameters/Transition/StopSeek/seek_position",seek_time)
if !movement_script.input_is_moving:
set("parameters/Transition/transition_request","Stop")
#set("parameters/VelocityDirection/Standing/transition_request","Stop")
#Rotate In Place
if movement_script.is_rotating_in_place:
if movement_script.rotation_difference_camera_mesh > 0:
set("parameters/Transition/transition_request","AnimTurnLeft")
else:
set("parameters/Transition/transition_request","AnimTurnRight")
#set("parameters/Turn/blend_amount" , 1 if movement_script.is_rotating_in_place else 0)
#set("parameters/RightOrLeft/blend_amount" ,0 if movement_script.rotation_difference_camera_mesh > 0 else 1)