bazar_alea/client/player/AnimationTree.gd

106 lines
4.8 KiB
GDScript3
Raw Normal View History

2023-11-14 21:41:08 +00:00
extends AnimationTree
class_name AnimBlend
2023-11-19 19:41:38 +00:00
@export var movement_script : CharacterMovementComponent
2023-11-14 21:41:08 +00:00
2023-11-19 19:41:38 +00:00
func _physics_process(_delta):
if !movement_script:
return
2023-11-14 21:41:08 +00:00
2023-11-19 19:41:38 +00:00
#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")
#print("Idle")
Global.MOVEMENT_STATE.in_air: # Air
pass
set("parameters/InAir/blend_amount" , 1.0)
#set("parameters/InAir/transition_request","Failling")
#print("Falling")
Global.MOVEMENT_STATE.mantling: # couverture
pass
Global.MOVEMENT_STATE.ragdoll:
pass
#set("parameters/Transition/transition_request","Idle")
#set("parameters/InAir/blend_amount" , 0.5)
2023-11-14 21:41:08 +00:00
2023-11-19 19:41:38 +00:00
func _physics_process__old(_delta):
if !movement_script:
return
2023-11-14 21:41:08 +00:00
2023-11-19 19:41:38 +00:00
#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)