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-20 22:18:02 +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:
|
2023-11-24 23:00:05 +00:00
|
|
|
Global.MOVEMENT_STATE.NONE:
|
2023-11-19 19:41:38 +00:00
|
|
|
pass
|
2023-11-24 23:00:05 +00:00
|
|
|
Global.MOVEMENT_STATE.GROUNDED: # Sol
|
2023-11-19 19:41:38 +00:00
|
|
|
set("parameters/InAir/blend_amount" , 0.0)
|
|
|
|
#set("parameters/TimeSeek/seek_request", 0.0)
|
|
|
|
#set("parameters/Transition/transition_request","Idle")
|
2023-11-24 23:00:05 +00:00
|
|
|
Global.MOVEMENT_STATE.IN_AIR: # Air
|
2023-11-19 19:41:38 +00:00
|
|
|
set("parameters/InAir/blend_amount" , 1.0)
|
|
|
|
#set("parameters/InAir/transition_request","Failling")
|
2023-11-24 23:00:05 +00:00
|
|
|
Global.MOVEMENT_STATE.MANTLING: # couverture
|
2023-11-19 19:41:38 +00:00
|
|
|
pass
|
2023-11-24 23:00:05 +00:00
|
|
|
Global.MOVEMENT_STATE.RAGDOLL:
|
2023-11-19 19:41:38 +00:00
|
|
|
pass
|
2023-12-11 23:19:21 +00:00
|
|
|
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", [])
|
2023-11-19 19:41:38 +00:00
|
|
|
#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:
|
2023-11-24 23:00:05 +00:00
|
|
|
Global.MOVEMENT_STATE.NONE:
|
2023-11-19 19:41:38 +00:00
|
|
|
pass
|
2023-11-24 23:00:05 +00:00
|
|
|
Global.MOVEMENT_STATE.GROUNDED: # Sol
|
2023-11-19 19:41:38 +00:00
|
|
|
set("parameters/InAir/blend_amount" , 0.0)
|
|
|
|
#set("parameters/Transition/transition_request","Idle")
|
2023-11-24 23:00:05 +00:00
|
|
|
Global.MOVEMENT_STATE.IN_AIR: # Air
|
2023-11-19 19:41:38 +00:00
|
|
|
set("parameters/InAir/blend_amount" , 1.0)
|
|
|
|
#set("parameters/InAir/transition_request","Failling")
|
2023-11-24 23:00:05 +00:00
|
|
|
Global.MOVEMENT_STATE.MANTLING: # couverture
|
2023-11-19 19:41:38 +00:00
|
|
|
pass
|
2023-11-24 23:00:05 +00:00
|
|
|
Global.MOVEMENT_STATE.RAGDOLL:
|
2023-11-19 19:41:38 +00:00
|
|
|
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")
|
2023-11-24 23:00:05 +00:00
|
|
|
if movement_script.gait == Global.GAIT.WALKING and movement_script.input_is_moving:
|
2023-11-19 19:41:38 +00:00
|
|
|
set("parameters/Transition/transition_request","WalkForward")
|
|
|
|
#set("parameters/VelocityDirection/Standing/transition_request","Walk")
|
|
|
|
#set("parameters/VelocityDirection/crouching/transition_request","Walk")
|
2023-11-24 23:00:05 +00:00
|
|
|
if movement_script.gait == Global.GAIT.RUNNING and movement_script.input_is_moving:
|
2023-11-19 19:41:38 +00:00
|
|
|
set("parameters/Transition/transition_request","JogForward")
|
|
|
|
#set("parameters/VelocityDirection/Standing/transition_request","Jog")
|
2023-11-24 23:00:05 +00:00
|
|
|
if movement_script.gait == Global.GAIT.SPRINTING and movement_script.input_is_moving:
|
2023-11-19 19:41:38 +00:00
|
|
|
set("parameters/Transition/transition_request","Run")
|
|
|
|
#set("parameters/Execution/transition_request","Run")
|
|
|
|
|
|
|
|
#Couch/stand switch
|
|
|
|
match movement_script.stance:
|
2023-11-24 23:00:05 +00:00
|
|
|
Global.STANCE.STANDING:
|
2023-11-19 19:41:38 +00:00
|
|
|
set("parameters/Transition/transition_request","stand")
|
|
|
|
#set("parameters/VelocityDirection/crouch/transition_request" , "stand")
|
2023-11-24 23:00:05 +00:00
|
|
|
Global.STANCE.CROUCHING:
|
2023-11-19 19:41:38 +00:00
|
|
|
set("parameters/Transition/transition_request","crouch")
|
|
|
|
#set("parameters/VelocityDirection/crouch/transition_request" , "crouch")
|
|
|
|
|
|
|
|
|
2023-11-24 23:00:05 +00:00
|
|
|
if movement_script.rotation_mode == Global.ROTATION_MODE.LOOKING_DIRECTION or \
|
|
|
|
movement_script.rotation_mode == Global.ROTATION_MODE.AIMING:
|
2023-11-19 19:41:38 +00:00
|
|
|
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)
|