From 367eea75aad309b434710f8dcf079e4d5c5ec6c4 Mon Sep 17 00:00:00 2001 From: AleaJactaEst Date: Sun, 19 Nov 2023 20:41:38 +0100 Subject: [PATCH] update --- client/player/AnimationTree.gd | 107 ++++++++++++-- client/player/Attributes/GameAttribute.gd | 2 +- client/player/Attributes/HealthAttribute.gd | 4 +- client/player/AttributesManager.gd | 3 +- client/player/CameraComponent.gd | 38 ++--- client/player/CharacterMovementComponent.gd | 126 ++++++++--------- client/player/CombatSystem.gd | 2 +- client/player/Global.gd | 30 ++-- client/player/LockSystem.gd | 70 --------- client/player/PlayerController.gd | 84 +++++------ client/player/PlayerGameplayComponent.gd | 16 +-- client/player/PlayerNetworkingComponent.gd | 12 +- client/player/PoseWarpingFunctions.gd | 66 +++++++++ client/player/TargetingComponent.gd | 2 +- client/player/character.gd | 29 ++++ client/player/character.tscn | 148 +++++++++++--------- client/project.godot | 15 +- client/scenes/DebugWindow.gd | 32 ++++- client/scenes/DebugWindow.tscn | 44 +++++- client/scenes/Window.gd | 4 +- client/scenes/main.gd | 27 ++-- client/scenes/main.tscn | 11 +- start-bazar-client.sh | 2 +- 23 files changed, 542 insertions(+), 332 deletions(-) delete mode 100644 client/player/LockSystem.gd create mode 100644 client/player/PoseWarpingFunctions.gd diff --git a/client/player/AnimationTree.gd b/client/player/AnimationTree.gd index a89a710..66a59ed 100644 --- a/client/player/AnimationTree.gd +++ b/client/player/AnimationTree.gd @@ -1,16 +1,105 @@ extends AnimationTree class_name AnimBlend -#@onready @export var movement_script : CharacterMovementComponent +@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") + #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) -# Called when the node enters the scene tree for the first time. -func _ready(): - pass # Replace with function body. +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") -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): - #if !movement_script: - # return - pass + 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) diff --git a/client/player/Attributes/GameAttribute.gd b/client/player/Attributes/GameAttribute.gd index 7ae086d..186057c 100644 --- a/client/player/Attributes/GameAttribute.gd +++ b/client/player/Attributes/GameAttribute.gd @@ -19,5 +19,5 @@ class_name GameAttribute var can_use:bool = true -func set_attribute(prev_v, current_v): +func set_attribute(_prev_v, _current_v): pass diff --git a/client/player/Attributes/HealthAttribute.gd b/client/player/Attributes/HealthAttribute.gd index 1bf33ee..c82fedb 100644 --- a/client/player/Attributes/HealthAttribute.gd +++ b/client/player/Attributes/HealthAttribute.gd @@ -4,14 +4,14 @@ class_name HealthAttribute @export_category("Visual Bar") @export var health_bar : ProgressBar -func set_attribute(prev_v, current_v): +func set_attribute(_prev_v, current_v): if !attributes_manager: return if current_v <= 0.0: # and not dead pass #death -func _process(delta): +func _process(_delta): if health_bar: health_bar.max_value = maximum_value health_bar.value = current_value diff --git a/client/player/AttributesManager.gd b/client/player/AttributesManager.gd index 3e9af25..cc4186e 100644 --- a/client/player/AttributesManager.gd +++ b/client/player/AttributesManager.gd @@ -8,5 +8,6 @@ var attributes : Dictionary func _ready(): for child in get_children(): if !(child is GameAttribute): - assert("Only GameAttribute childs are allowed") + continue + #assert( !(child is GameAttribute), "Only GameAttribute childs are allowed") attributes[child.attribute_name] = child diff --git a/client/player/CameraComponent.gd b/client/player/CameraComponent.gd index b2ff4db..ab372b1 100644 --- a/client/player/CameraComponent.gd +++ b/client/player/CameraComponent.gd @@ -13,26 +13,26 @@ class_name CameraComponent ##################################### var CameraHOffset := 0.0 -@export var view_angle : Global.view_angle = Global.view_angle.right_shoulder: +@export var view_angle : Global.VIEW_ANGLE = Global.VIEW_ANGLE.right_shoulder: get: return view_angle set(Newview_angle): -# if view_mode == Global.view_mode.first_person: +# if view_mode == Global.VIEW_MODE.first_person: # return view_angle = Newview_angle if Camera: match Newview_angle: - Global.view_angle.right_shoulder: + Global.VIEW_ANGLE.right_shoulder: CameraHOffset = 0.45 update_camera_offset() - Global.view_angle.left_shoulder: + Global.VIEW_ANGLE.left_shoulder: CameraHOffset = -0.45 update_camera_offset() - Global.view_angle.head: + Global.VIEW_ANGLE.head: CameraHOffset = 0.0 update_camera_offset() -@export var view_mode : Global.view_mode = Global.view_mode.third_person : +@export var view_mode : Global.VIEW_MODE = Global.VIEW_MODE.third_person : get: return view_mode set(Newview_mode): view_mode = Newview_mode @@ -40,12 +40,12 @@ var CameraHOffset := 0.0 VObject.rotation.x = 0.0 if SpringArm: match view_mode: - Global.view_mode.first_person: - view_angle = Global.view_angle.head - PlayerRef.rotation_mode = Global.rotation_mode.looking_direction + Global.VIEW_MODE.first_person: + view_angle = Global.VIEW_ANGLE.head + PlayerRef.rotation_mode = Global.ROTATION_MODE.looking_direction SpringArm.spring_length = -0.4 VObject = Camera - Global.view_mode.third_person: + Global.VIEW_MODE.third_person: SpringArm.spring_length = 1.75 VObject = SpringArm @@ -71,20 +71,20 @@ func _physics_process(delta): if camera_settings.camera_change_fov_on_speed and PlayerRef.actual_velocity.length() > camera_settings.camera_fov_change_starting_speed: smooth_fov(current_fov + clampf((PlayerRef.actual_velocity.length()-camera_settings.camera_fov_change_starting_speed)*(camera_settings.camera_max_fov_change/10.0),0,camera_settings.camera_max_fov_change)) - SpringArm.position = SpringArm.position.lerp((get_parent().global_position + spring_arm_position_relative_to_player) if view_mode == Global.view_mode.third_person else first_person_camera_bone.global_position,(1/camera_settings.camera_inertia) if view_mode == Global.view_mode.third_person else 1.0) + SpringArm.position = SpringArm.position.lerp((get_parent().global_position + spring_arm_position_relative_to_player) if view_mode == Global.VIEW_MODE.third_person else first_person_camera_bone.global_position,(1/camera_settings.camera_inertia) if view_mode == Global.VIEW_MODE.third_person else 1.0) camera_v = clamp(camera_v,deg_to_rad(camera_vertical_min),deg_to_rad(camera_vertical_max)) HObject.rotation.y = lerp(HObject.rotation.y,camera_h,delta * acceleration_h) VObject.rotation.x = lerp(VObject.rotation.x,camera_v,delta * acceleration_v) match PlayerRef.rotation_mode: - Global.rotation_mode.aiming: - if PlayerRef.gait == Global.gait.sprinting: # character can't sprint while aiming - PlayerRef.gait = Global.gait.running + Global.ROTATION_MODE.aiming: + if PlayerRef.gait == Global.GAIT.sprinting: # character can't sprint while aiming + PlayerRef.gait = Global.GAIT.running smooth_fov(60.0) - Global.rotation_mode.velocity_direction: + Global.ROTATION_MODE.velocity_direction: smooth_fov(90.0) - Global.rotation_mode.looking_direction: + Global.ROTATION_MODE.looking_direction: smooth_fov(90.0) @@ -103,13 +103,13 @@ func smooth_fov(_current_fov:float): tween.tween_callback(func(): changing_view=false) -func smooth_camera_transition(pos:Vector3, look_at:Vector3, duration:float = 1.0 ,ease:Tween.EaseType = Tween.EASE_IN_OUT, trans:Tween.TransitionType = Tween.TRANS_LINEAR): +func smooth_camera_transition(pos:Vector3, look_at:Vector3, duration:float = 1.0 ,ease_:Tween.EaseType = Tween.EASE_IN_OUT, trans:Tween.TransitionType = Tween.TRANS_LINEAR): # Camera.global_position = Camera.to_global(Camera.global_position) Camera.top_level = true var tween := create_tween() tween.set_parallel() - tween.tween_property(Camera,"position",pos,duration).set_ease(ease).set_trans(trans) - tween.tween_method(func(arr:Array): Camera.look_at_from_position(arr[0],arr[1]),[Camera.position,look_at],[pos,look_at],duration).set_ease(ease).set_trans(trans) + tween.tween_property(Camera,"position",pos,duration).set_ease(ease_).set_trans(trans) + tween.tween_method(func(arr:Array): Camera.look_at_from_position(arr[0],arr[1]),[Camera.position,look_at],[pos,look_at],duration).set_ease(ease_).set_trans(trans) var reseting : bool = false func reset_camera_transition(smooth_transition: bool = true): diff --git a/client/player/CharacterMovementComponent.gd b/client/player/CharacterMovementComponent.gd index 0eb5a42..c1a91f1 100644 --- a/client/player/CharacterMovementComponent.gd +++ b/client/player/CharacterMovementComponent.gd @@ -155,26 +155,26 @@ var animation_is_moving_backward_relative_to_camera : bool var animation_velocity : Vector3 #status -var movement_state = Global.movement_state.grounded -var movement_action = Global.movement_action.none +@export var movement_state = Global.MOVEMENT_STATE.grounded +var movement_action = Global.MOVEMENT_ACTION.none @export_category("States") -@export var rotation_mode : Global.rotation_mode = Global.rotation_mode.velocity_direction : +@export var rotation_mode : Global.ROTATION_MODE = Global.ROTATION_MODE.velocity_direction : get: return rotation_mode set(Newrotation_mode): rotation_mode = Newrotation_mode update_character_movement() -@export var gait : Global.gait = Global.gait.walking : +@export var gait : Global.GAIT = Global.GAIT.walking : # Demarche (attente, marche, ...) get: return gait set(Newgait): gait = Newgait update_character_movement() -@export var stance : Global.stance = Global.stance.standing : +@export var stance : Global.STANCE = Global.STANCE.standing : # Position (debout, accroupi, ..) set(Newstance): stance = Newstance update_character_movement() -@export var overlay_state = Global.overlay_state +@export var overlay_state = Global.OVERLAY_STATE @export_category("Animations") @export var TurnLeftAnim : String = "TurnLeft": @@ -193,11 +193,11 @@ var movement_action = Global.movement_action.none set(value): IdleAnim = value update_animations() -@export var WalkForwardAnim : String = "Walk": +@export var WalkForwardAnim : String = "WalkForward": set(value): WalkForwardAnim = value update_animations() -@export var WalkBackwardAnim : String = "WalkingBackward": +@export var WalkBackwardAnim : String = "WalkBackward": set(value): WalkBackwardAnim = value update_animations() @@ -231,49 +231,49 @@ var movement_action = Global.movement_action.none func update_animations(): if !anim_ref: return - - anim_ref.tree_root.get_node("AnimTurnLeft").animation = TurnLeftAnim - anim_ref.tree_root.get_node("AnimTurnRight").animation = TurnRightAnim - anim_ref.tree_root.get_node("FallAnimation").animation = FallingAnim - #var velocity_direction : AnimationNodeBlendTree = anim_ref.tree_root.get_node("VelocityDirection") - anim_ref.tree_root.get_node("Idle").animation = IdleAnim - anim_ref.tree_root.get_node("WalkForward").animation = WalkForwardAnim - anim_ref.tree_root.get_node("WalkBackward").animation = WalkBackwardAnim - anim_ref.tree_root.get_node("JogForward").animation = JogForwardAnim - anim_ref.tree_root.get_node("JogBackward").animation = JogBackwardAnim - anim_ref.tree_root.get_node("Run").animation = RunAnim - anim_ref.tree_root.get_node("StopAnim").animation = StopAnim - anim_ref.tree_root.get_node("CrouchIdle").animation = CrouchIdleAnim - anim_ref.tree_root.get_node("CrouchWalkingForward").animation = CrouchWalkAnim + anim_ref.get_tree_root().get_node("AnimTurnLeft").set_animation(TurnLeftAnim) + anim_ref.get_tree_root().get_node("AnimTurnRight").animation = TurnRightAnim + anim_ref.get_tree_root().get_node("FallAnimation").animation = FallingAnim + #var velocity_direction : AnimationNodeBlendTree = anim_ref.get_tree_root().get_node("VelocityDirection") + anim_ref.get_tree_root().get_node("Idle").animation = IdleAnim + anim_ref.get_tree_root().get_node("WalkForward").animation = WalkForwardAnim + anim_ref.get_tree_root().get_node("WalkBackward").animation = WalkBackwardAnim + anim_ref.get_tree_root().get_node("JogForward").animation = JogForwardAnim + anim_ref.get_tree_root().get_node("JogBackward").animation = JogBackwardAnim + anim_ref.get_tree_root().get_node("Run").animation = RunAnim + anim_ref.get_tree_root().get_node("StopAnim").animation = StopAnim + anim_ref.get_tree_root().get_node("CrouchIdle").animation = CrouchIdleAnim + anim_ref.get_tree_root().get_node("CrouchWalkingForward").animation = CrouchWalkAnim + func update_character_movement(): match rotation_mode: - Global.rotation_mode.velocity_direction: + Global.ROTATION_MODE.velocity_direction: # if skeleton_ref: # skeleton_ref.modification_stack.enabled = false tilt = false match stance: - Global.stance.standing: + Global.STANCE.standing: current_movement_data = velocity_direction_standing_data - Global.stance.crouching: + Global.STANCE.crouching: current_movement_data = velocity_direction_crouch_data - Global.rotation_mode.looking_direction: + Global.ROTATION_MODE.looking_direction: # if skeleton_ref: # skeleton_ref.modification_stack.enabled = false #Change to true when Godot fixes the bug. tilt = true match stance: - Global.stance.standing: + Global.STANCE.standing: current_movement_data = looking_direction_standing_data - Global.stance.crouching: + Global.STANCE.crouching: current_movement_data = looking_direction_crouch_data - Global.rotation_mode.aiming: + Global.ROTATION_MODE.aiming: match stance: - Global.stance.standing: + Global.STANCE.standing: current_movement_data = aim_standing_data - Global.stance.crouching: + Global.STANCE.crouching: current_movement_data = aim_crouch_data ##################################### @@ -310,13 +310,13 @@ func _ready(): update_animations() update_character_movement() -#var pose_warping_instance = pose_warping.new() +var pose_warping_instance = PoseWarping.new() func _process(delta): calc_animation_data() - var orientation_warping_condition = rotation_mode != Global.rotation_mode.velocity_direction and movement_state == Global.movement_state.grounded and movement_action == Global.movement_action.none and gait != Global.gait.sprinting and input_is_moving - #pose_warping_instance.orientation_warping( orientation_warping_condition,camera_root.HObject,animation_velocity,skeleton_ref,"Hips",["Spine","Spine1","Spine2"],0.0,delta) + var orientation_warping_condition = rotation_mode != Global.ROTATION_MODE.velocity_direction and movement_state == Global.MOVEMENT_STATE.grounded and movement_action == Global.MOVEMENT_ACTION.none and gait != Global.GAIT.sprinting and input_is_moving + pose_warping_instance.orientation_warping( orientation_warping_condition,camera_root.HObject,animation_velocity,skeleton_ref,"Hips",["Spine","Spine1","Spine2"],0.0,delta) func _physics_process(delta): #Debug() @@ -327,43 +327,43 @@ func _physics_process(delta): # animation_stride_warping() match movement_state: - Global.movement_state.none: + Global.MOVEMENT_STATE.none: pass - Global.movement_state.grounded: + Global.MOVEMENT_STATE.grounded: #------------------ Rotate Character Mesh ------------------# match movement_action: - Global.movement_action.none: + Global.MOVEMENT_ACTION.none: match rotation_mode: - Global.rotation_mode.velocity_direction: + Global.ROTATION_MODE.velocity_direction: if (is_moving and input_is_moving) or (actual_velocity * Vector3(1.0,0.0,1.0)).length() > 0.5: smooth_character_rotation(actual_velocity,calc_grounded_rotation_rate(),delta) - Global.rotation_mode.looking_direction: + Global.ROTATION_MODE.looking_direction: if (is_moving and input_is_moving) or (actual_velocity * Vector3(1.0,0.0,1.0)).length() > 0.5: - smooth_character_rotation(-camera_root.HObject.transform.basis.z if gait != Global.gait.sprinting else actual_velocity,calc_grounded_rotation_rate(),delta) + smooth_character_rotation(-camera_root.HObject.transform.basis.z if gait != Global.GAIT.sprinting else actual_velocity,calc_grounded_rotation_rate(),delta) rotate_in_place_check() - Global.rotation_mode.aiming: + Global.ROTATION_MODE.aiming: if (is_moving and input_is_moving) or (actual_velocity * Vector3(1.0,0.0,1.0)).length() > 0.5: smooth_character_rotation(-camera_root.HObject.transform.basis.z,calc_grounded_rotation_rate(),delta) rotate_in_place_check() - Global.movement_action.rolling: + Global.MOVEMENT_ACTION.rolling: if input_is_moving == true: smooth_character_rotation(input_acceleration ,2.0,delta) - Global.movement_state.in_air: + Global.MOVEMENT_STATE.in_air: #------------------ Rotate Character Mesh In Air ------------------# match rotation_mode: - Global.rotation_mode.velocity_direction: + Global.ROTATION_MODE.velocity_direction: smooth_character_rotation(actual_velocity if (actual_velocity * Vector3(1.0,0.0,1.0)).length() > 1.0 else -camera_root.HObject.transform.basis.z,5.0,delta) - Global.rotation_mode.looking_direction: + Global.ROTATION_MODE.looking_direction: smooth_character_rotation(actual_velocity if (actual_velocity * Vector3(1.0,0.0,1.0)).length() > 1.0 else -camera_root.HObject.transform.basis.z,5.0,delta) - Global.rotation_mode.aiming: + Global.ROTATION_MODE.aiming: smooth_character_rotation(-camera_root.HObject.transform.basis.z ,15.0,delta) #------------------ Mantle Check ------------------# if input_is_moving == true: mantle_check() - Global.movement_state.mantling: + Global.MOVEMENT_STATE.mantling: pass - Global.movement_state.ragdoll: + Global.MOVEMENT_STATE.ragdoll: pass #------------------ Crouch ------------------# @@ -374,10 +374,10 @@ func _physics_process(delta): character_node.velocity.y = lerp(character_node.velocity.y,vertical_velocity.y - character_node.get_floor_normal().y,delta * gravity) character_node.move_and_slide() if ground_check.is_colliding() and is_flying == false: - movement_state = Global.movement_state.grounded + movement_state = Global.MOVEMENT_STATE.grounded else: await get_tree().create_timer(0.1).timeout #wait a moment to see if the character lands fast (this means that the character didn't fall, but stepped down a bit.) - movement_state = Global.movement_state.in_air + movement_state = Global.MOVEMENT_STATE.in_air if character_node is CharacterBody3D: vertical_velocity += Vector3.DOWN * gravity * delta if character_node is CharacterBody3D and character_node.is_on_ceiling(): @@ -401,10 +401,10 @@ func crouch_update(delta): ground_check.position.y = -(collision_shape_ref.shape.height/2)+collision_shape_ref.position.y + 0.2#Just a small margin - if stance == Global.stance.crouching: + if stance == Global.STANCE.crouching: collision_shape_ref.shape.height -= crouch_switch_speed * delta /2 mesh_ref.transform.origin.y += crouch_switch_speed * delta /1.5 - elif stance == Global.stance.standing and not head_bonked: + elif stance == Global.STANCE.standing and not head_bonked: collision_shape_ref.shape.height += crouch_switch_speed * delta /2 mesh_ref.transform.origin.y -= crouch_switch_speed * delta /1.5 elif head_bonked: @@ -431,7 +431,7 @@ func stair_move(): var stair_top_collision = direct_state.intersect_ray(climb_ray_info) if stair_top_collision: if stair_top_collision.position.y - character_node.global_position.y > 0 and stair_top_collision.position.y - character_node.global_position.y < 0.15: - movement_state = Global.movement_state.grounded + movement_state = Global.MOVEMENT_STATE.grounded is_moving_on_stair = true character_node.position.y += stair_top_collision.position.y - character_node.global_position.y character_node.global_position += Vector3(0, 0, 0.01).rotated(Vector3.UP,movement_direction) @@ -451,7 +451,7 @@ func smooth_character_rotation(Target:Vector3,nodelerpspeed,delta): mesh_ref.rotation.y = lerp_angle(mesh_ref.rotation.y, atan2(Target.x,Target.z) , delta * nodelerpspeed) -func set_bone_x_rotation(skeleton,bone_name, x_rot,CharacterRootNode): +func set_bone_x_rotation(skeleton,bone_name, x_rot, _CharacterRootNode): var bone = skeleton.find_bone(bone_name) var bone_transform : Transform3D = skeleton.global_pose_to_local_pose(bone,skeleton.get_bone_global_pose_no_override(bone)) var rotate_amount = x_rot @@ -474,7 +474,7 @@ func animation_stride_warping(): #this is currently being worked on and tested, var Feet : Array = ["RightFoot","LeftFoot"] var Thighs : Array = ["RightUpLeg","LeftUpLeg"] - var hips_distance_to_ground + #var hips_distance_to_ground var stride_scale : float = 1.0 for Foot in Feet: #Get Bones @@ -483,7 +483,7 @@ func animation_stride_warping(): #this is currently being worked on and tested, var thigh_bone = skeleton_ref.find_bone(Thighs[Feet.find(Foot)]) var thigh_transform = skeleton_ref.get_bone_global_pose_no_override(thigh_bone) - var thigh_angle = thigh_transform.basis.get_euler().x + #var thigh_angle = thigh_transform.basis.get_euler().x #Calculate var stride_direction : Vector3 = Vector3.FORWARD # important to use in orientation warping @@ -493,9 +493,9 @@ func animation_stride_warping(): #this is currently being worked on and tested, return #Failed to get a plane origin/ we are probably in air var scale_origin = Plane(stride_direction,stride_warping_plane_origin).project(bone_transform.origin) - var anim_speed = pow(hips_transform.origin.distance_to(bone_transform.origin),2) - pow(hips_transform.origin.y,2) - anim_speed = sqrt(abs(anim_speed)) - stride_scale = clampf(distance_in_each_frame/anim_speed,0.0,2.0) + var anim_speed_ = pow(hips_transform.origin.distance_to(bone_transform.origin),2) - pow(hips_transform.origin.y,2) + anim_speed_ = sqrt(abs(anim_speed_)) + stride_scale = clampf(distance_in_each_frame/anim_speed_,0.0,2.0) # print(test_sphere.global_position) var foot_warped_location : Vector3 = scale_origin + (bone_transform.origin - scale_origin) * stride_scale @@ -511,11 +511,11 @@ func calc_grounded_rotation_rate(): if input_is_moving == true: match gait: - Global.gait.walking: + Global.GAIT.walking: return lerp(current_movement_data.idle_rotation_rate,current_movement_data.walk_rotation_rate, Global.map_range_clamped((actual_velocity * Vector3(1.0,0.0,1.0)).length(),0.0,current_movement_data.walk_speed,0.0,1.0)) * clamp(aim_rate_h,1.0,3.0) - Global.gait.running: + Global.GAIT.running: return lerp(current_movement_data.walk_rotation_rate,current_movement_data.run_rotation_rate, Global.map_range_clamped((actual_velocity * Vector3(1.0,0.0,1.0)).length(),current_movement_data.walk_speed,current_movement_data.run_speed,1.0,2.0)) * clamp(aim_rate_h,1.0,3.0) - Global.gait.sprinting: + Global.GAIT.sprinting: return lerp(current_movement_data.run_rotation_rate,current_movement_data.sprint_rotation_rate, Global.map_range_clamped((actual_velocity * Vector3(1.0,0.0,1.0)).length(),current_movement_data.run_speed,current_movement_data.sprint_speed,2.0,3.0)) * clamp(aim_rate_h,1.0,2.5) else: return current_movement_data.idle_rotation_rate * clamp(aim_rate_h,1.0,3.0) @@ -546,7 +546,7 @@ var PrevVelocity :Vector3 ## Adds input to move the character, should be called when Idle too, to execute deacceleration for CharacterBody3D or reset velocity for RigidBody3D. ## when Idle speed and direction should be passed as 0, and deacceleration passed, or leave them empty. -func add_movement_input(direction: Vector3 = Vector3.ZERO, Speed: float = 0, Acceleration: float = deacceleration if character_node is CharacterBody3D else 0) -> void: +func add_movement_input(direction: Vector3 = Vector3.ZERO, Speed: float = 0, Acceleration: float = deacceleration if character_node is CharacterBody3D else 0.0) -> void: var max_speed : float = Speed input_direction = direction diff --git a/client/player/CombatSystem.gd b/client/player/CombatSystem.gd index d6f1063..645036e 100644 --- a/client/player/CombatSystem.gd +++ b/client/player/CombatSystem.gd @@ -10,7 +10,7 @@ var team_id : int = 0 var last_attacker_id : int @rpc("any_peer","reliable") -func damage(dmg:float,attacker_player_peer_id:int,impact_point:Vector3=Vector3.ZERO, impact_force:float=0.0, impact_bone_name:String=""): +func damage(dmg:float,attacker_player_peer_id:int,_impact_point:Vector3=Vector3.ZERO, _impact_force:float=0.0, _impact_bone_name:String=""): last_attacker_id = attacker_player_peer_id var health = attribute_map.attributes["health"].current_value diff --git a/client/player/Global.gd b/client/player/Global.gd index a2bad85..76c85cc 100644 --- a/client/player/Global.gd +++ b/client/player/Global.gd @@ -1,16 +1,26 @@ extends Node #------------------ Player Enums ------------------# -enum gait {walking , running , sprinting} -enum movement_state {none , grounded , in_air , mantling, ragdoll} -enum movement_action {none ,low_mantle , high_mantle , rolling , getting_up} -enum overlay_state {default , rifle , pistol} -enum rotation_mode {velocity_direction , looking_direction , aiming} -enum stance {standing , crouching} -enum view_mode {third_person , first_person} -enum view_angle {right_shoulder , left_shoulder , head} -enum mantle_type {high_mantle , low_mantle, falling_catch} -enum movement_direction {forward , right, left, backward} +# Demarche (Attendre, Marcher, Courir, Pic de vitesse +enum GAIT {waiting, walking , running , sprinting} +# Sol, Air, Couverture, poupee de chiffon +enum MOVEMENT_STATE {none , grounded , in_air , mantling, ragdoll} +# +enum MOVEMENT_ACTION {none ,low_mantle , high_mantle , rolling , getting_up} +# Fusis, Pistolet +enum OVERLAY_STATE {default , rifle , pistol} +# +enum ROTATION_MODE {velocity_direction , looking_direction , aiming} +# Position (debout, accroupi) +enum STANCE {standing , crouching} +# +enum VIEW_MODE {third_person , first_person} +# +enum VIEW_ANGLE {right_shoulder , left_shoulder , head} +# Type de cape/manteau +enum MANTLE_TYPE {high_mantle , low_mantle, falling_catch} +# Direction du mouvement (devant, droite, gauche, arriere) +enum MOVEMENT_DIRECTION {forward , right, left, backward} func map_range_clamped(value,InputMin,InputMax,OutputMin,OutputMax): diff --git a/client/player/LockSystem.gd b/client/player/LockSystem.gd deleted file mode 100644 index 1c198cd..0000000 --- a/client/player/LockSystem.gd +++ /dev/null @@ -1,70 +0,0 @@ -extends Node -class_name LockSystem - -#The array of locks that are presently applied. The player can perform an action if this array is empty. -#The locks can be used for any manner of things: player movement in cutscenes, restricting dialogue choices, door open conditions etc -var _locks = [] - -var lock_count : int : - get: - return _locks.size() - -#An event to hook into - primarily for debugging. -signal Lock_Added(lockName:String) -signal Lock_Removed(lockName:String) - -#This one should only emit if is_locked would have changed. -signal Lock_Status_Changed(newStatus:bool) - -#A getter to see if any locks are being applied -@export var is_locked : bool : - get: - return _check_is_locked() - -#If a lock called lock_name hasn't already been added, adds one. -func add_lock(lock_name:String): - #Don't add duplicate locks - if(contains_lock(lock_name)): - print_debug("Lock %lock is already added." % lock_name) - return - else: - #Add locks and emit events - _locks.append(lock_name) - emit_signal("Lock_Added", lock_name) - #if this is the first and only lock, the locked status has changed to true - if(_locks.size() == 1): - Lock_Status_Changed.emit(true) - return; - -#Removes a lock with the name lock_name. Prints a message if it's not in there. -func remove_lock(lock_name:String): - if(contains_lock(lock_name)): - _locks.erase(lock_name) - #If there's now zero locks remaining, emit event - if(_locks.size() == 0): - Lock_Status_Changed.emit(false) - else: - print_debug("Lock %lock cannot be removed as it isn't there." % lock_name) - -#Returns true if _locks has any entries added, false if no locks are being applied -func _check_is_locked(): - return _locks.size() > 0; - -#Returns true if a lock called lock_name is already added to _locks -func contains_lock(lock_name:String): - for lock in _locks: - if lock == lock_name: - return true; - return false; - -#Prints all current locks - useful for tracking down issues when locks haven't been lifted -func debug_locks(): - var log = "Printing all locks" - for lock in _locks: - print_debug("\n" + str(lock)) - -#To be used for debug - for when the locks need to be bypassed to test. -func debug_release_all_locks(): - for lock in _locks: - Lock_Removed.emit(lock) - _locks.clear(); diff --git a/client/player/PlayerController.gd b/client/player/PlayerController.gd index 6a07cc7..a1526d4 100644 --- a/client/player/PlayerController.gd +++ b/client/player/PlayerController.gd @@ -20,10 +20,6 @@ var h_rotation :float var previous_rotation_mode var direction := Vector3.ZERO -##################################### -#Locks System -@export var lock_system : LockSystem -##################################### @export var mouse_sensitivity : float = 0.01 @@ -41,13 +37,9 @@ func possess_character(p_character_component:CharacterMovementComponent,control: character_component.camera_root.Camera.current = networking.is_local_authority() -func _physics_process(delta): +func _physics_process(_delta): if !networking.is_local_authority(): return - if lock_system != null && lock_system.is_locked: - direction = Vector3.ZERO - character_component.add_movement_input() - return #------------------ Input Movement ------------------# h_rotation = character_component.camera_root.HObject.transform.basis.get_euler().y @@ -58,9 +50,9 @@ func _physics_process(delta): remap(v_rotation,-PI/2,PI/2,-1.0,1.0) if character_component.is_flying == true else 0.0, Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up")) direction = direction.rotated(Vector3.UP,h_rotation).normalized() - if character_component.gait == Global.gait.sprinting : + if character_component.gait == Global.GAIT.sprinting : character_component.add_movement_input(direction, character_component.current_movement_data.sprint_speed,character_component.current_movement_data.sprint_acceleration) - elif character_component.gait == Global.gait.running: + elif character_component.gait == Global.GAIT.running: character_component.add_movement_input(direction, character_component.current_movement_data.run_speed,character_component.current_movement_data.run_acceleration) else: character_component.add_movement_input(direction, character_component.current_movement_data.walk_speed,character_component.current_movement_data.walk_acceleration) @@ -72,55 +64,55 @@ func _physics_process(delta): #------------------ Input Crouch ------------------# if UsingCrouchToggle == false: if Input.is_action_pressed("ui_crouch"): - if character_component.stance != Global.stance.crouching: - character_component.stance = Global.stance.crouching + if character_component.stance != Global.STANCE.crouching: + character_component.stance = Global.STANCE.crouching else: - if character_component.stance != Global.stance.standing: - character_component.stance = Global.stance.standing + if character_component.stance != Global.STANCE.standing: + character_component.stance = Global.STANCE.standing else: if Input.is_action_just_pressed("ui_crouch"): - character_component.stance = Global.stance.standing if character_component.stance == Global.stance.crouching else Global.stance.crouching + character_component.stance = Global.STANCE.standing if character_component.stance == Global.STANCE.crouching else Global.STANCE.crouching #------------------ Sprint ------------------# if UsingSprintToggle: if Input.is_action_just_pressed("ui_sprint"): - if character_component.gait == Global.gait.walking: - character_component.gait = Global.gait.running - elif character_component.gait == Global.gait.running: - character_component.gait = Global.gait.sprinting - elif character_component.gait == Global.gait.sprinting: - character_component.gait = Global.gait.walking + if character_component.gait == Global.GAIT.walking: + character_component.gait = Global.GAIT.running + elif character_component.gait == Global.GAIT.running: + character_component.gait = Global.GAIT.sprinting + elif character_component.gait == Global.GAIT.sprinting: + character_component.gait = Global.GAIT.walking else: if Input.is_action_just_pressed("ui_sprint"): - if character_component.gait == Global.gait.walking: - character_component.gait = Global.gait.running - elif character_component.gait == Global.gait.running: - character_component.gait = Global.gait.sprinting + if character_component.gait == Global.GAIT.walking: + character_component.gait = Global.GAIT.running + elif character_component.gait == Global.GAIT.running: + character_component.gait = Global.GAIT.sprinting if Input.is_action_just_released("ui_sprint"): - if character_component.gait == Global.gait.sprinting or character_component.gait == Global.gait.walking: - character_component.gait = Global.gait.walking - elif character_component.gait == Global.gait.running: + if character_component.gait == Global.GAIT.sprinting or character_component.gait == Global.GAIT.walking: + character_component.gait = Global.GAIT.walking + elif character_component.gait == Global.GAIT.running: await get_tree().create_timer(0.4).timeout - if character_component.gait == Global.gait.running: - character_component.gait = Global.gait.walking + if character_component.gait == Global.GAIT.running: + character_component.gait = Global.GAIT.walking #------------------ Input Aim ------------------# if Input.is_action_pressed("ui_aim"): - if character_component.rotation_mode != Global.rotation_mode.aiming: + if character_component.rotation_mode != Global.ROTATION_MODE.aiming: previous_rotation_mode = character_component.rotation_mode - character_component.rotation_mode = Global.rotation_mode.aiming + character_component.rotation_mode = Global.ROTATION_MODE.aiming else: - if character_component.rotation_mode == Global.rotation_mode.aiming: + if character_component.rotation_mode == Global.ROTATION_MODE.aiming: character_component.rotation_mode = previous_rotation_mode #------------------ Jump ------------------#= if OnePressJump == true: if Input.is_action_just_pressed("ui_jump"): - if character_component.stance != Global.stance.standing: - character_component.stance = Global.stance.standing + if character_component.stance != Global.STANCE.standing: + character_component.stance = Global.STANCE.standing else: character_component.jump() else: if Input.is_action_pressed("ui_jump"): - if character_component.stance != Global.stance.standing: - character_component.stance = Global.stance.standing + if character_component.stance != Global.STANCE.standing: + character_component.stance = Global.STANCE.standing else: character_component.jump() @@ -153,7 +145,7 @@ func _input(event): if Input.is_action_just_released("ui_switch_camera_view"): if view_changed_recently == false: view_changed_recently = true - character_component.camera_root.view_angle = character_component.camera_root.view_angle + 1 if character_component.camera_root.view_angle < 2 else 0 + character_component.camera_root.view_angle = (character_component.camera_root.view_angle + 1) as Global.VIEW_ANGLE if character_component.camera_root.view_angle < 2 else 0 as Global.VIEW_ANGLE await get_tree().create_timer(0.3).timeout view_changed_recently = false else: @@ -161,7 +153,7 @@ func _input(event): if Input.is_action_just_pressed("ui_switch_camera_view"): await get_tree().create_timer(0.2).timeout if view_changed_recently == false: - character_component.camera_root.view_mode = character_component.camera_root.view_mode + 1 if character_component.camera_root.view_mode < 1 else 0 + character_component.camera_root.view_mode = (character_component.camera_root.view_mode + 1) as Global.VIEW_MODE if character_component.camera_root.view_mode < 1 else 0 as Global.VIEW_MODE view_changed_recently = true if networking.is_local_authority(): if event.is_action_pressed("ui_enable_sdfgi"): @@ -175,13 +167,7 @@ func _input(event): character_component.ragdoll = true - if character_component.rotation_mode == Global.rotation_mode.velocity_direction: + if character_component.rotation_mode == Global.ROTATION_MODE.velocity_direction: if character_component.camera_root != null: - if character_component.camera_root.view_mode == Global.view_mode.first_person: - character_component.camera_root.view_mode = Global.view_mode.third_person - - if(Input.is_action_pressed("ui_pause")): - if(lock_system.contains_lock("pauseGame")): - lock_system.remove_lock("pauseGame") - else: - lock_system.add_lock("pauseGame") + if character_component.camera_root.view_mode == Global.VIEW_MODE.first_person: + character_component.camera_root.view_mode = Global.VIEW_MODE.third_person diff --git a/client/player/PlayerGameplayComponent.gd b/client/player/PlayerGameplayComponent.gd index 958bbea..0d75837 100644 --- a/client/player/PlayerGameplayComponent.gd +++ b/client/player/PlayerGameplayComponent.gd @@ -14,11 +14,11 @@ func _ready(): func _process(delta): - if gait != Global.gait.sprinting and stamina_use: + if gait != Global.GAIT.sprinting and stamina_use: stamina_attribute.being_used = false - if gait == Global.gait.sprinting and stamina_use: + if gait == Global.GAIT.sprinting and stamina_use: if !stamina_attribute.can_use or stamina_attribute.current_value < stamina_energy_consumption*delta: - gait = Global.gait.running + gait = Global.GAIT.running return stamina_attribute.being_used = true stamina_attribute.current_value -= stamina_energy_consumption*delta @@ -28,9 +28,9 @@ func _physics_process(delta): # Debug() if !networking.is_local_authority(): if input_is_moving: - if gait == Global.gait.sprinting: + if gait == Global.GAIT.sprinting: add_movement_input(input_direction, current_movement_data.sprint_speed,current_movement_data.sprint_acceleration) - elif gait == Global.gait.running: + elif gait == Global.GAIT.running: add_movement_input(input_direction, current_movement_data.run_speed,current_movement_data.run_acceleration) else: add_movement_input(input_direction, current_movement_data.walk_speed,current_movement_data.walk_acceleration) @@ -40,12 +40,12 @@ func _physics_process(delta): return #------------------ Look At ------------------# match rotation_mode: - Global.rotation_mode.velocity_direction: + Global.ROTATION_MODE.velocity_direction: if input_is_moving: ik_look_at(actual_velocity + Vector3(0.0,1.0,0.0)) - Global.rotation_mode.looking_direction: + Global.ROTATION_MODE.looking_direction: ik_look_at(camera_root.SpringArm.transform.basis.z * 2.0 + Vector3(0.0,1.5,0.0)) - Global.rotation_mode.aiming: + Global.ROTATION_MODE.aiming: ik_look_at(camera_root.SpringArm.transform.basis.z * 2.0 + Vector3(0.0,1.5,0.0)) #func Debug(): # $Status/Label.text = "InputSpeed : %s" % input_velocity.length() diff --git a/client/player/PlayerNetworkingComponent.gd b/client/player/PlayerNetworkingComponent.gd index 2165812..a559099 100644 --- a/client/player/PlayerNetworkingComponent.gd +++ b/client/player/PlayerNetworkingComponent.gd @@ -6,7 +6,7 @@ class_name PlayerNetworkingComponent var sync_camera_h_transform : Transform3D var sync_camera_v_transform : Transform3D -var sync_view_mode : Global.view_mode = Global.view_mode.third_person +var sync_view_mode : Global.VIEW_MODE = Global.VIEW_MODE.third_person var sync_CameraHOffset : float var sync_position : Vector3: set(value): @@ -15,11 +15,11 @@ var sync_position : Vector3: var sync_mesh_rotation : Vector3 var sync_direction : Vector3 var sync_input_is_moving : bool -var sync_gait : Global.gait = Global.gait.walking -var sync_rotation_mode : Global.rotation_mode = Global.rotation_mode.velocity_direction -var sync_stance : Global.stance = Global.stance.standing -var sync_movement_state : Global.movement_state = Global.movement_state.grounded -var sync_movement_action : Global.movement_action = Global.movement_action.none +var sync_gait : Global.GAIT = Global.GAIT.walking +var sync_rotation_mode : Global.ROTATION_MODE = Global.ROTATION_MODE.velocity_direction +var sync_stance : Global.STANCE = Global.STANCE.standing +var sync_movement_state : Global.MOVEMENT_STATE = Global.MOVEMENT_STATE.grounded +var sync_movement_action : Global.MOVEMENT_ACTION = Global.MOVEMENT_ACTION.none var sync_velocity : Vector3 var processed_position : bool diff --git a/client/player/PoseWarpingFunctions.gd b/client/player/PoseWarpingFunctions.gd new file mode 100644 index 0000000..481f506 --- /dev/null +++ b/client/player/PoseWarpingFunctions.gd @@ -0,0 +1,66 @@ +extends Node +class_name PoseWarping + +## For Predicting Stop Location +## it uses a linear equation : d = v*t + 0.5 * a * t^2 +## v is velocity. t is time. a is acceleration +func CalculateStopLocation(CurrentCharacterLocation:Vector3,Velocity:Vector3,deacceleration:Vector3,_delta): + var time = CalculateStopTime(Velocity,deacceleration) + return CurrentCharacterLocation + (Velocity * time + 0.5*deacceleration*pow(time,2)) + +func CalculateStopTime(Velocity:Vector3,deacceleration:Vector3): + var time = Velocity.length() / deacceleration.length() + return time + + +var previous_direction : float +var orientation_direction : float +var cleared_override : bool = true +func orientation_warping(enabled:bool,CameraObject, Velocity:Vector3, skeleton_ref:Skeleton3D, Hip :String= "Hips", Spines :Array[String]= ["Spine","Spine1","Spine2"], Offset := 0.0, delta :float= 1.0, turn_rate :float= 10.0): + + if !enabled and !cleared_override: + set_bone_y_rotation(skeleton_ref,Hip,0,false) + for bone in Spines: + set_bone_y_rotation(skeleton_ref,bone,0,false) + cleared_override = true + if is_equal_approx(Velocity.length(),0.0) or !enabled: + return + cleared_override = false + var CameraAngle :Quaternion = Quaternion(Vector3(0,1,0),atan2(-CameraObject.transform.basis.z.z, -CameraObject.transform.basis.z.x)) + var VelocityAngle :Quaternion = Quaternion(Vector3(0,1,0),atan2(Velocity.z, Velocity.x)) + var IsMovingBackwardRelativeToCamera :bool = false if -Velocity.rotated(Vector3.UP,-CameraObject.transform.basis.get_euler().y).z >= -0.1 else true + var IsMovingLeftRelativeToCamera :bool = false if -Velocity.rotated(Vector3.UP,-CameraObject.transform.basis.get_euler().y).x >= -0.1 else true + var rotation_difference_camera_velocity :float = CameraAngle.angle_to(VelocityAngle) + previous_direction = orientation_direction + orientation_direction = rotation_difference_camera_velocity + if IsMovingBackwardRelativeToCamera: + # Make the legs face forward just like the forward walking + orientation_direction *= -1 + orientation_direction = orientation_direction + PI + + + # Set Left or Right + if IsMovingLeftRelativeToCamera: + orientation_direction *= -1 + + if IsMovingBackwardRelativeToCamera: + # since we rotated the legs to face forward, then the right and left will be reversed + # so we need to reverse it back again after getting the right and left values + orientation_direction *= -1 + + orientation_direction = clampf(lerp_angle(previous_direction,orientation_direction,delta*turn_rate),-PI/2, PI/2) + #Orient bones to face the forward direction + + set_bone_y_rotation(skeleton_ref,Hip,orientation_direction) + for bone in Spines: + set_bone_y_rotation(skeleton_ref,bone,(-orientation_direction/(Spines.size()))+Offset) + + +func set_bone_y_rotation(skeleton:Skeleton3D,bone_name:String, y_rot:float, presistant:bool=true): + var bone = skeleton.find_bone(bone_name) + var bone_transform : Transform3D = skeleton.get_bone_global_pose_no_override(bone) + bone_transform = bone_transform.rotated(Vector3(0,1,0), y_rot) + + skeleton.set_bone_global_pose_override(bone, bone_transform,1.0,presistant) + + diff --git a/client/player/TargetingComponent.gd b/client/player/TargetingComponent.gd index 6627220..488b0b8 100644 --- a/client/player/TargetingComponent.gd +++ b/client/player/TargetingComponent.gd @@ -24,7 +24,7 @@ signal detected(object: Node3D) #this activates for all func _ready(): detection_raycast.add_exception(get_parent()) -func _process(delta): +func _process(_delta): if detection_raycast.is_colliding(): if detected_player == detection_raycast.get_collider() or detected_object == detection_raycast.get_collider(): return diff --git a/client/player/character.gd b/client/player/character.gd index 4e9ee10..04b8017 100644 --- a/client/player/character.gd +++ b/client/player/character.gd @@ -27,6 +27,7 @@ func set_otherplayer(value:bool): func _ready(): $SpringArm3D/Camera3D.set_current(false) + $PlayerGameplayComponent.update_animations() func set_current_camera(): @@ -35,3 +36,31 @@ func set_current_camera(): func set_id(value:int): $PlayerNetworkingComponent.set_id(value) + + +func get_animation() -> String: + return $AnimationTree.get("parameters/Transition/current_state") + \ + ", " + str($AnimationTree.get("parameters/InAir/blend_amount")) + \ + ", active:" + str($AnimationTree.is_active()) + \ + ", " + str($AnimationPlayer.get_current_animation()) + \ + ", " + str($AnimationPlayer.get_current_animation_position()) + \ + ", " + str($AnimationPlayer.get_autoplay()) + \ + ", playing:" + str($AnimationPlayer.is_playing()) + \ + ", " + str($AnimationTree.get("parameters/Transition/current_state")) + \ + ", " + str($AnimationTree.get("parameters/Transition/current_index")) + + +func get_gait() -> String: + return Global.GAIT.keys()[$PlayerGameplayComponent.gait] + + +func get_stance() -> String: + return Global.STANCE.keys()[$PlayerGameplayComponent.stance] + + +func get_rotation_mode() -> String: + return Global.ROTATION_MODE.keys()[$PlayerGameplayComponent.rotation_mode] + + +func get_movement_state() -> String: + return Global.MOVEMENT_STATE.keys()[$PlayerGameplayComponent.movement_state] diff --git a/client/player/character.tscn b/client/player/character.tscn index 78b029a..af05fd8 100644 --- a/client/player/character.tscn +++ b/client/player/character.tscn @@ -6,7 +6,6 @@ [ext_resource type="Script" path="res://player/PlayerController.gd" id="6_nwle3"] [ext_resource type="Script" path="res://player/PlayerNetworkingComponent.gd" id="6_uat01"] [ext_resource type="Script" path="res://player/PlayerGameplayComponent.gd" id="7_bwjer"] -[ext_resource type="Script" path="res://player/LockSystem.gd" id="7_gldfq"] [ext_resource type="Resource" uid="uid://cl10j5xgiv3nt" path="res://player/standing_movement_values.tres" id="8_2lh6g"] [ext_resource type="Script" path="res://player/TargetingComponent.gd" id="8_mbdru"] [ext_resource type="Resource" uid="uid://ci00blt7nkvkp" path="res://player/crouch_mouvements_valuestres.tres" id="9_1v6ud"] @@ -277,6 +276,7 @@ blend_shape_mode = 0 [sub_resource type="Animation" id="Animation_5w3q6"] resource_name = "CrouchIdle" length = 2.51667 +loop_mode = 1 tracks/0/type = "position_3d" tracks/0/imported = true tracks/0/enabled = true @@ -652,6 +652,7 @@ tracks/52/keys = PackedFloat32Array(0, 1, 0.580893, -0.0268012, -0.0152882, 0.81 [sub_resource type="Animation" id="Animation_8e8gk"] resource_name = "CrouchWalkingForward" length = 1.05 +loop_mode = 1 tracks/0/type = "position_3d" tracks/0/imported = true tracks/0/enabled = true @@ -1027,6 +1028,7 @@ tracks/52/keys = PackedFloat32Array(0, 1, 0.339601, -0.0167263, -0.00604042, 0.9 [sub_resource type="Animation" id="Animation_ndv3n"] resource_name = "Falling" length = 0.366667 +loop_mode = 1 tracks/0/type = "position_3d" tracks/0/imported = true tracks/0/enabled = true @@ -3655,6 +3657,7 @@ tracks/52/keys = PackedFloat32Array(0, 1, 0.359152, -0.000236487, -0.0293793, 0. [sub_resource type="Animation" id="Animation_tu1sn"] resource_name = "JogForward" length = 0.833333 +loop_mode = 1 tracks/0/type = "position_3d" tracks/0/imported = true tracks/0/enabled = true @@ -4030,6 +4033,7 @@ tracks/52/keys = PackedFloat32Array(0, 1, 0.347456, -0.0167762, -0.00590023, 0.9 [sub_resource type="Animation" id="Animation_besle"] resource_name = "Jogbackward" length = 0.733333 +loop_mode = 1 tracks/0/type = "position_3d" tracks/0/imported = true tracks/0/enabled = true @@ -4780,6 +4784,7 @@ tracks/52/keys = PackedFloat32Array(0, 1, 0.352065, -0.016805, -0.00581728, 0.93 [sub_resource type="Animation" id="Animation_j5sce"] resource_name = "Run" length = 0.733333 +loop_mode = 1 tracks/0/type = "position_3d" tracks/0/imported = true tracks/0/enabled = true @@ -5905,6 +5910,7 @@ tracks/52/keys = PackedFloat32Array(0, 1, 0.339601, -0.0167263, -0.00604036, 0.9 [sub_resource type="Animation" id="Animation_x8jyy"] resource_name = "TurnLeft" length = 0.533333 +loop_mode = 1 tracks/0/type = "position_3d" tracks/0/imported = true tracks/0/enabled = true @@ -6280,6 +6286,7 @@ tracks/52/keys = PackedFloat32Array(0, 1, 0.359108, -0.0002373, -0.0293815, 0.93 [sub_resource type="Animation" id="Animation_kr4pb"] resource_name = "TurnRight" length = 0.533333 +loop_mode = 1 tracks/0/type = "position_3d" tracks/0/imported = true tracks/0/enabled = true @@ -6655,6 +6662,7 @@ tracks/52/keys = PackedFloat32Array(0, 1, 0.359108, -0.000237304, -0.0293813, 0. [sub_resource type="Animation" id="Animation_6kwge"] resource_name = "Walk" length = 1.18333 +loop_mode = 1 tracks/0/type = "position_3d" tracks/0/imported = true tracks/0/enabled = true @@ -7030,6 +7038,7 @@ tracks/52/keys = PackedFloat32Array(0, 1, 0.343156, -0.0157443, -0.00561167, 0.9 [sub_resource type="Animation" id="Animation_cgqvn"] resource_name = "WalkingBackward" length = 1.23333 +loop_mode = 1 tracks/0/type = "position_3d" tracks/0/imported = true tracks/0/enabled = true @@ -7443,6 +7452,8 @@ animation = &"Falling" [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_suon5"] animation = &"Idle" +[sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_0jhs5"] + [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_a4444"] animation = &"Jogbackward" @@ -7469,33 +7480,30 @@ input_1/reset = true input_2/name = "AnimTurnRight" input_2/auto_advance = false input_2/reset = true -input_3/name = "FallAnimation" +input_3/name = "WalkForward" input_3/auto_advance = false input_3/reset = true -input_4/name = "WalkForward" +input_4/name = "WalkBackward" input_4/auto_advance = false input_4/reset = true -input_5/name = "WalkBackward" +input_5/name = "JogForward" input_5/auto_advance = false input_5/reset = true -input_6/name = "JogForward" +input_6/name = "JogBackward" input_6/auto_advance = false input_6/reset = true -input_7/name = "JogBackward" +input_7/name = "Run" input_7/auto_advance = false input_7/reset = true -input_8/name = "Run" +input_8/name = "Stop" input_8/auto_advance = false input_8/reset = true -input_9/name = "StopAnim" +input_9/name = "CrouchIdle" input_9/auto_advance = false input_9/reset = true -input_10/name = "CrouchIdle" +input_10/name = "CrouchWalkingForward" input_10/auto_advance = false input_10/reset = true -input_11/name = "CrouchWalkingForward" -input_11/auto_advance = false -input_11/reset = true [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_vneb5"] animation = &"WalkingBackward" @@ -7504,6 +7512,7 @@ animation = &"WalkingBackward" animation = &"Walk" [sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_vhngy"] +graph_offset = Vector2(-649.114, 875.502) nodes/AnimTurnLeft/node = SubResource("AnimationNodeAnimation_1bw6h") nodes/AnimTurnLeft/position = Vector2(-200, 1160) nodes/AnimTurnRight/node = SubResource("AnimationNodeAnimation_w4s02") @@ -7513,9 +7522,11 @@ nodes/CrouchIdle/position = Vector2(-200, 2320) nodes/CrouchWalkingForward/node = SubResource("AnimationNodeAnimation_mn3vl") nodes/CrouchWalkingForward/position = Vector2(-200, 2440) nodes/FallAnimation/node = SubResource("AnimationNodeAnimation_kkw8t") -nodes/FallAnimation/position = Vector2(-200, 1420) +nodes/FallAnimation/position = Vector2(600, 1940) nodes/Idle/node = SubResource("AnimationNodeAnimation_suon5") nodes/Idle/position = Vector2(-200, 1000) +nodes/InAir/node = SubResource("AnimationNodeBlend2_0jhs5") +nodes/InAir/position = Vector2(860, 1700) nodes/JogBackward/node = SubResource("AnimationNodeAnimation_a4444") nodes/JogBackward/position = Vector2(-200, 1960) nodes/JogForward/node = SubResource("AnimationNodeAnimation_0ofmx") @@ -7524,16 +7535,16 @@ nodes/Run/node = SubResource("AnimationNodeAnimation_7e4cx") nodes/Run/position = Vector2(-200, 2080) nodes/StopAnim/node = SubResource("AnimationNodeAnimation_d8ckl") nodes/StopAnim/position = Vector2(-460, 2180) -nodes/TimeSeek/node = SubResource("AnimationNodeTimeSeek_ktjog") -nodes/TimeSeek/position = Vector2(-200, 2200) +nodes/StopSeek/node = SubResource("AnimationNodeTimeSeek_ktjog") +nodes/StopSeek/position = Vector2(-200, 2200) nodes/Transition/node = SubResource("AnimationNodeTransition_vpwll") -nodes/Transition/position = Vector2(180, 1740) +nodes/Transition/position = Vector2(340, 1500) nodes/WalkBackward/node = SubResource("AnimationNodeAnimation_vneb5") nodes/WalkBackward/position = Vector2(-200, 1720) nodes/WalkForward/node = SubResource("AnimationNodeAnimation_o38l4") nodes/WalkForward/position = Vector2(-200, 1540) -nodes/output/position = Vector2(480, 1740) -node_connections = [&"output", 0, &"Transition", &"TimeSeek", 0, &"StopAnim", &"Transition", 0, &"Idle", &"Transition", 1, &"AnimTurnLeft", &"Transition", 2, &"AnimTurnRight", &"Transition", 3, &"FallAnimation", &"Transition", 4, &"WalkForward", &"Transition", 5, &"WalkBackward", &"Transition", 6, &"JogForward", &"Transition", 7, &"JogBackward", &"Transition", 8, &"Run", &"Transition", 9, &"TimeSeek", &"Transition", 10, &"CrouchIdle", &"Transition", 11, &"CrouchWalkingForward"] +nodes/output/position = Vector2(1140, 1700) +node_connections = [&"output", 0, &"InAir", &"InAir", 0, &"Transition", &"InAir", 1, &"FallAnimation", &"StopSeek", 0, &"StopAnim", &"Transition", 0, &"Idle", &"Transition", 1, &"AnimTurnLeft", &"Transition", 2, &"AnimTurnRight", &"Transition", 3, &"WalkForward", &"Transition", 4, &"WalkBackward", &"Transition", 5, &"JogForward", &"Transition", 6, &"JogBackward", &"Transition", 7, &"Run", &"Transition", 8, &"StopSeek", &"Transition", 9, &"CrouchIdle", &"Transition", 10, &"CrouchWalkingForward"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_bfs86"] radius = 0.339864 @@ -7551,43 +7562,43 @@ bones/0/name = "Hips" bones/0/parent = -1 bones/0/rest = Transform3D(0.544576, -0.0348814, -0.837986, 0.0102475, 0.999337, -0.0349382, 0.838649, 0.0104393, 0.544573, -0.000172998, 0.901879, -0.00179914) bones/0/enabled = true -bones/0/position = Vector3(0.00283597, 0.931562, 0.00331031) -bones/0/rotation = Quaternion(-0.0403509, -0.372282, -0.0153027, 0.927116) +bones/0/position = Vector3(0.00568129, 0.928223, -0.00851084) +bones/0/rotation = Quaternion(-0.0380304, -0.369041, -0.0142976, 0.928524) bones/0/scale = Vector3(1, 1, 1) bones/1/name = "Spine" bones/1/parent = 0 bones/1/rest = Transform3D(0.99963, -0.0129189, 0.0239171, 0.01122, 0.997494, 0.0698543, -0.0247596, -0.0695601, 0.99727, 4.88944e-09, 0.0992349, -0.0122733) bones/1/enabled = true bones/1/position = Vector3(4.88944e-09, 0.0992349, -0.0122733) -bones/1/rotation = Quaternion(-0.0136409, 0.0404221, -0.00533626, 0.999075) +bones/1/rotation = Quaternion(-0.0119361, 0.0402718, -0.00588803, 0.9991) bones/1/scale = Vector3(1, 1, 1) bones/2/name = "Spine1" bones/2/parent = 1 bones/2/rest = Transform3D(0.99985, -0.015446, 0.00786788, 0.0155655, 0.999761, -0.0153596, -0.00762876, 0.0154798, 0.999851, -2.79397e-09, 0.11732, 1.86265e-09) bones/2/enabled = true bones/2/position = Vector3(-2.79397e-09, 0.11732, 1.86265e-09) -bones/2/rotation = Quaternion(0.0938403, 0.0820147, -0.00714181, 0.992178) +bones/2/rotation = Quaternion(0.0997416, 0.082021, -0.00858619, 0.99159) bones/2/scale = Vector3(1, 1, 1) bones/3/name = "Spine2" bones/3/parent = 2 bones/3/rest = Transform3D(0.999844, -0.014346, 0.0103258, 0.0156141, 0.990645, -0.135571, -0.00828427, 0.135711, 0.990714, -2.79397e-09, 0.134588, -2.51457e-08) bones/3/enabled = true bones/3/position = Vector3(-2.79397e-09, 0.134588, -2.51457e-08) -bones/3/rotation = Quaternion(0.153535, 0.0814301, -0.0120967, 0.984708) +bones/3/rotation = Quaternion(0.158797, 0.0811451, -0.0133842, 0.98388) bones/3/scale = Vector3(1, 1, 1) bones/4/name = "Neck" bones/4/parent = 3 bones/4/rest = Transform3D(0.968778, 0.12654, 0.213204, -0.00181599, 0.863542, -0.504273, -0.247921, 0.488142, 0.836811, 2.48197e-07, 0.150325, 0.00792907) bones/4/enabled = true bones/4/position = Vector3(2.48197e-07, 0.150325, 0.00792907) -bones/4/rotation = Quaternion(0.132742, -0.0096362, 0.00324981, 0.991099) +bones/4/rotation = Quaternion(0.116529, -0.010733, 0.00307788, 0.993125) bones/4/scale = Vector3(1, 1, 1) bones/5/name = "Head" bones/5/parent = 4 bones/5/rest = Transform3D(0.840773, 0.330252, 0.428993, -0.33245, 0.940342, -0.0723432, -0.427291, -0.0817944, 0.900406, 5.58794e-09, 0.107895, 5.21541e-08) bones/5/enabled = true bones/5/position = Vector3(5.58794e-09, 0.107895, 5.21541e-08) -bones/5/rotation = Quaternion(-0.0458908, 0.170505, -0.0565952, 0.982659) +bones/5/rotation = Quaternion(-0.0214122, 0.164158, -0.0656016, 0.984017) bones/5/scale = Vector3(1, 1, 1) bones/6/name = "HeadTop_End" bones/6/parent = 5 @@ -7615,42 +7626,42 @@ bones/9/parent = 3 bones/9/rest = Transform3D(-0.250988, 0.959361, -0.128958, 0.025503, -0.126623, -0.991623, -0.967654, -0.252174, 0.0073142, 0.0610582, 0.0911044, 0.00705553) bones/9/enabled = true bones/9/position = Vector3(0.0610582, 0.0911044, 0.00705553) -bones/9/rotation = Quaternion(-0.470188, -0.538757, 0.56958, -0.405268) +bones/9/rotation = Quaternion(-0.493435, -0.517291, 0.572693, -0.401192) bones/9/scale = Vector3(1, 1, 1) bones/10/name = "LeftArm" bones/10/parent = 9 bones/10/rest = Transform3D(0.845869, -0.51692, -0.131522, 0.093338, 0.386222, -0.917671, 0.52516, 0.763954, 0.374941, 7.45058e-09, 0.129223, 3.95812e-08) bones/10/enabled = true bones/10/position = Vector3(7.45058e-09, 0.129223, 3.95812e-08) -bones/10/rotation = Quaternion(0.533032, -0.0735466, 0.145765, 0.830193) +bones/10/rotation = Quaternion(0.520818, -0.0848315, 0.142397, 0.837422) bones/10/scale = Vector3(1, 1, 1) bones/11/name = "LeftForeArm" bones/11/parent = 10 bones/11/rest = Transform3D(0.138967, -0.989426, 0.0415226, 0.989436, 0.140472, 0.0358277, -0.0412816, 0.0361051, 0.998495, -4.47035e-08, 0.274229, -7.45058e-09) bones/11/enabled = true bones/11/position = Vector3(-4.47035e-08, 0.274229, -7.45058e-09) -bones/11/rotation = Quaternion(-0.00663084, 0.10084, 0.45349, 0.885514) +bones/11/rotation = Quaternion(-0.0130679, 0.0912165, 0.440925, 0.892801) bones/11/scale = Vector3(1, 1, 1) bones/12/name = "LeftHand" bones/12/parent = 11 bones/12/rest = Transform3D(0.746359, -0.304314, 0.591895, 0.184003, 0.949028, 0.255908, -0.639601, -0.0820888, 0.764311, 6.0536e-09, 0.276326, -1.49012e-08) bones/12/enabled = true bones/12/position = Vector3(6.0536e-09, 0.276326, -1.49012e-08) -bones/12/rotation = Quaternion(-0.152616, 0.122807, -0.00625228, 0.980606) +bones/12/rotation = Quaternion(-0.158749, 0.124717, -0.00609249, 0.979391) bones/12/scale = Vector3(1, 1, 1) bones/13/name = "LeftHandMiddle1" bones/13/parent = 12 bones/13/rest = Transform3D(0.98654, 0.118644, -0.112532, -0.118809, 0.0472127, -0.991794, -0.112357, 0.991814, 0.0606732, -3.12924e-07, 0.127755, -7.63685e-08) bones/13/enabled = true bones/13/position = Vector3(-3.12924e-07, 0.127755, -7.63685e-08) -bones/13/rotation = Quaternion(0.137686, 0.00255728, -0.0680427, 0.988133) +bones/13/rotation = Quaternion(0.12676, 0.00562846, -0.0833771, 0.988407) bones/13/scale = Vector3(1, 1, 1) bones/14/name = "LeftHandMiddle2" bones/14/parent = 13 bones/14/rest = Transform3D(0.980685, 0.110739, -0.161229, -0.112737, -0.353585, -0.928584, -0.159838, 0.928824, -0.334271, -7.45058e-09, 0.0361397, -5.21541e-08) bones/14/enabled = true bones/14/position = Vector3(-7.45058e-09, 0.0361397, -5.21541e-08) -bones/14/rotation = Quaternion(0.2025, -0.00140622, 0.0157577, 0.979154) +bones/14/rotation = Quaternion(0.19154, -0.0013185, 0.0145333, 0.981376) bones/14/scale = Vector3(1, 1, 1) bones/15/name = "LeftHandMiddle3" bones/15/parent = 14 @@ -7671,14 +7682,14 @@ bones/17/parent = 12 bones/17/rest = Transform3D(0.922249, -0.296379, 0.248225, 0.374682, 0.843413, -0.385056, -0.0952333, 0.448123, 0.888885, -0.0300309, 0.0378879, 0.0216701) bones/17/enabled = true bones/17/position = Vector3(-0.0300309, 0.0378879, 0.0216701) -bones/17/rotation = Quaternion(0.284303, 0.116152, 0.179992, 0.934496) +bones/17/rotation = Quaternion(0.287054, 0.113951, 0.18725, 0.932498) bones/17/scale = Vector3(1, 1, 1) bones/18/name = "LeftHandThumb2" bones/18/parent = 17 bones/18/rest = Transform3D(0.793061, 0.491162, -0.360297, -0.562049, 0.818065, -0.121947, 0.234851, 0.299216, 0.924832, 1.19209e-07, 0.0474499, -2.44938e-07) bones/18/enabled = true bones/18/position = Vector3(1.19209e-07, 0.0474499, -2.44938e-07) -bones/18/rotation = Quaternion(-0.00754959, 0.000821922, -0.000678718, 0.999971) +bones/18/rotation = Quaternion(-0.00730394, 0.00107365, -0.000654198, 0.999973) bones/18/scale = Vector3(1, 1, 1) bones/19/name = "LeftHandThumb3" bones/19/parent = 18 @@ -7699,14 +7710,14 @@ bones/21/parent = 12 bones/21/rest = Transform3D(0.983723, 0.142189, -0.109869, -0.119058, 0.0577917, -0.991204, -0.134589, 0.988151, 0.0737798, -0.0282207, 0.122666, 0.00231682) bones/21/enabled = true bones/21/position = Vector3(-0.0282207, 0.122666, 0.00231682) -bones/21/rotation = Quaternion(0.0394915, -0.00499261, 0.0619782, 0.997283) +bones/21/rotation = Quaternion(0.0363674, -0.00617189, 0.0608838, 0.997463) bones/21/scale = Vector3(1, 1, 1) bones/22/name = "LeftHandIndex2" bones/22/parent = 21 bones/22/rest = Transform3D(0.978949, 0.10384, -0.175717, -0.111366, -0.44972, -0.8862, -0.171047, 0.887113, -0.428688, 1.11759e-07, 0.0389198, -5.96046e-08) bones/22/enabled = true bones/22/position = Vector3(1.11759e-07, 0.0389198, -5.96046e-08) -bones/22/rotation = Quaternion(0.153716, -0.000982702, -0.00552012, 0.988099) +bones/22/rotation = Quaternion(0.146303, -0.000814461, -0.0064394, 0.989219) bones/22/scale = Vector3(1, 1, 1) bones/23/name = "LeftHandIndex3" bones/23/parent = 22 @@ -7727,14 +7738,14 @@ bones/25/parent = 12 bones/25/rest = Transform3D(0.991492, 0.0540781, -0.118406, -0.118263, -0.00584495, -0.992965, -0.0543897, 0.99852, 0.000600219, 0.0221662, 0.12147, -9.90927e-05) bones/25/enabled = true bones/25/position = Vector3(0.0221662, 0.12147, -9.90927e-05) -bones/25/rotation = Quaternion(0.277906, -0.0198568, -0.113505, 0.953672) +bones/25/rotation = Quaternion(0.268357, -0.0141495, -0.128229, 0.954642) bones/25/scale = Vector3(1, 1, 1) bones/26/name = "LeftHandRing2" bones/26/parent = 25 bones/26/rest = Transform3D(0.981497, 0.113181, -0.154445, -0.116659, -0.286137, -0.951061, -0.151835, 0.951481, -0.267639, -3.72529e-08, 0.036012, -1.11759e-07) bones/26/enabled = true bones/26/position = Vector3(-3.72529e-08, 0.036012, -1.11759e-07) -bones/26/rotation = Quaternion(0.289165, 0.00178166, 0.0251886, 0.956946) +bones/26/rotation = Quaternion(0.277406, 0.00169659, 0.0244819, 0.960439) bones/26/scale = Vector3(1, 1, 1) bones/27/name = "LeftHandRing3" bones/27/parent = 26 @@ -7755,14 +7766,14 @@ bones/29/parent = 12 bones/29/rest = Transform3D(0.991785, 0.0101279, -0.127516, -0.126197, -0.0855001, -0.988314, -0.0209122, 0.996287, -0.0835196, 0.0472581, 0.109082, 0.00226384) bones/29/enabled = true bones/29/position = Vector3(0.0472581, 0.109082, 0.00226384) -bones/29/rotation = Quaternion(0.303528, -0.0212722, -0.147611, 0.941079) +bones/29/rotation = Quaternion(0.292807, -0.0150013, -0.160961, 0.942407) bones/29/scale = Vector3(1, 1, 1) bones/30/name = "LeftHandPinky2" bones/30/parent = 29 bones/30/rest = Transform3D(0.989305, 0.129006, -0.068066, -0.049097, -0.144898, -0.988228, -0.13735, 0.981001, -0.137015, -5.96046e-08, 0.0413669, -1.49012e-08) bones/30/enabled = true bones/30/position = Vector3(-5.96046e-08, 0.0413669, -1.49012e-08) -bones/30/rotation = Quaternion(0.349955, 0.0118476, 0.050039, 0.935354) +bones/30/rotation = Quaternion(0.337869, 0.011273, 0.0499161, 0.939801) bones/30/scale = Vector3(1, 1, 1) bones/31/name = "LeftHandPinky3" bones/31/parent = 30 @@ -7783,42 +7794,42 @@ bones/33/parent = 3 bones/33/rest = Transform3D(-0.214833, -0.949432, 0.228968, -0.0511495, -0.223182, -0.973434, 0.975311, -0.220837, -0.000616074, -0.061057, 0.0911053, 0.00705566) bones/33/enabled = true bones/33/position = Vector3(-0.061057, 0.0911053, 0.00705566) -bones/33/rotation = Quaternion(0.52132, -0.499581, 0.538164, 0.434769) +bones/33/rotation = Quaternion(0.543087, -0.479528, 0.539733, 0.428718) bones/33/scale = Vector3(1, 1, 1) bones/34/name = "RightArm" bones/34/parent = 33 bones/34/rest = Transform3D(0.555382, 0.714901, -0.424814, -0.786414, 0.285417, -0.547804, -0.270377, 0.63832, 0.720724, -2.23517e-08, 0.129223, 9.12696e-08) bones/34/enabled = true bones/34/position = Vector3(-2.23517e-08, 0.129223, 9.12696e-08) -bones/34/rotation = Quaternion(0.515463, 0.0816633, 0.0766891, 0.849557) +bones/34/rotation = Quaternion(0.507388, 0.0925246, 0.0783521, 0.853145) bones/34/scale = Vector3(1, 1, 1) bones/35/name = "RightForeArm" bones/35/parent = 34 bones/35/rest = Transform3D(-0.491194, 0.870247, -0.0374029, -0.870282, -0.488505, 0.0630281, 0.0365786, 0.0635101, 0.997311, 7.45058e-09, 0.274776, -3.72529e-08) bones/35/enabled = true bones/35/position = Vector3(7.45058e-09, 0.274776, -3.72529e-08) -bones/35/rotation = Quaternion(0.0638918, -0.0637895, -0.432987, 0.896868) +bones/35/rotation = Quaternion(0.0537691, -0.0473773, -0.427371, 0.901232) bones/35/scale = Vector3(1, 1, 1) bones/36/name = "RightHand" bones/36/parent = 35 bones/36/rest = Transform3D(0.953663, 0.121098, 0.275431, -0.18063, 0.962538, 0.202223, -0.240624, -0.242603, 0.939811, 7.45058e-09, 0.276868, 5.96046e-08) bones/36/enabled = true bones/36/position = Vector3(7.45058e-09, 0.276868, 5.96046e-08) -bones/36/rotation = Quaternion(0.109362, -0.0028724, -0.0446916, 0.992993) +bones/36/rotation = Quaternion(0.0963163, -0.0188782, -0.0578338, 0.99349) bones/36/scale = Vector3(1, 1, 1) bones/37/name = "RightHandMiddle1" bones/37/parent = 36 bones/37/rest = Transform3D(0.986308, -0.119644, 0.1135, 0.119813, 0.0469439, -0.991686, 0.113321, 0.991706, 0.060636, 3.50177e-07, 0.127755, -8.9407e-08) bones/37/enabled = true bones/37/position = Vector3(3.50177e-07, 0.127755, -8.9407e-08) -bones/37/rotation = Quaternion(0.111089, 0.00854235, 0.024559, 0.99347) +bones/37/rotation = Quaternion(0.11078, 0.00841764, 0.0251424, 0.993491) bones/37/scale = Vector3(1, 1, 1) bones/38/name = "RightHandMiddle2" bones/38/parent = 37 bones/38/rest = Transform3D(0.980361, -0.111685, 0.162538, 0.114835, -0.346749, -0.930902, 0.160328, 0.931285, -0.327114, 6.70552e-08, 0.0361398, -1.02445e-07) bones/38/enabled = true bones/38/position = Vector3(6.70552e-08, 0.0361398, -1.02445e-07) -bones/38/rotation = Quaternion(0.312804, 0.00174462, -0.0215883, 0.949571) +bones/38/rotation = Quaternion(0.261216, 0.00138701, -0.0168361, 0.965132) bones/38/scale = Vector3(1, 1, 1) bones/39/name = "RightHandMiddle3" bones/39/parent = 38 @@ -7839,14 +7850,14 @@ bones/41/parent = 36 bones/41/rest = Transform3D(0.940404, 0.29207, -0.174168, -0.340048, 0.811489, -0.475239, 0.00253238, 0.506143, 0.862446, 0.0300309, 0.037888, 0.0216703) bones/41/enabled = true bones/41/position = Vector3(0.0300309, 0.037888, 0.0216703) -bones/41/rotation = Quaternion(0.202641, 0.0250613, -0.228236, 0.951954) +bones/41/rotation = Quaternion(0.201819, 0.0252891, -0.223257, 0.953303) bones/41/scale = Vector3(1, 1, 1) bones/42/name = "RightHandThumb2" bones/42/parent = 41 bones/42/rest = Transform3D(0.793791, -0.608189, -0.00159446, 0.595053, 0.777184, -0.204689, 0.125729, 0.161531, 0.978826, -1.2666e-07, 0.0474498, -2.68221e-07) bones/42/enabled = true bones/42/position = Vector3(-1.2666e-07, 0.0474498, -2.68221e-07) -bones/42/rotation = Quaternion(0.00623671, 0.00160337, 0.181413, 0.983386) +bones/42/rotation = Quaternion(0.00695255, 0.00144822, 0.186603, 0.98241) bones/42/scale = Vector3(1, 1, 1) bones/43/name = "RightHandThumb3" bones/43/parent = 42 @@ -7867,14 +7878,14 @@ bones/45/parent = 36 bones/45/rest = Transform3D(0.978763, -0.172845, 0.110213, 0.120904, 0.0525683, -0.991271, 0.165542, 0.983545, 0.0723496, 0.0282207, 0.122666, 0.00231693) bones/45/enabled = true bones/45/position = Vector3(0.0282207, 0.122666, 0.00231693) -bones/45/rotation = Quaternion(0.0382943, 0.009724, 0.010592, 0.999163) +bones/45/rotation = Quaternion(0.0402283, 0.0101502, 0.0086425, 0.999102) bones/45/scale = Vector3(1, 1, 1) bones/46/name = "RightHandIndex2" bones/46/parent = 45 bones/46/rest = Transform3D(0.978593, -0.104714, 0.177172, 0.106914, -0.476935, -0.872412, 0.175853, 0.872679, -0.45553, 1.49012e-07, 0.0389196, -8.75443e-08) bones/46/enabled = true bones/46/position = Vector3(1.49012e-07, 0.0389196, -8.75443e-08) -bones/46/rotation = Quaternion(0.146455, 0.000136748, 0.0097476, 0.989169) +bones/46/rotation = Quaternion(0.146494, 0.000141189, 0.00974489, 0.989164) bones/46/scale = Vector3(1, 1, 1) bones/47/name = "RightHandIndex3" bones/47/parent = 46 @@ -7895,14 +7906,14 @@ bones/49/parent = 36 bones/49/rest = Transform3D(0.991829, -0.0281871, 0.124419, 0.122843, -0.0520322, -0.991061, 0.0344089, 0.998247, -0.0481446, -0.0221661, 0.12147, -9.89214e-05) bones/49/enabled = true bones/49/position = Vector3(-0.0221661, 0.12147, -9.89214e-05) -bones/49/rotation = Quaternion(0.21164, -0.0064362, 0.0648184, 0.975175) +bones/49/rotation = Quaternion(0.185929, -0.00865894, 0.0675539, 0.9802) bones/49/scale = Vector3(1, 1, 1) bones/50/name = "RightHandRing2" bones/50/parent = 49 bones/50/rest = Transform3D(0.982662, -0.117406, 0.143498, 0.122607, -0.169092, -0.977944, 0.139081, 0.978583, -0.151765, -7.45058e-09, 0.036012, 0) bones/50/enabled = true bones/50/position = Vector3(-7.45058e-09, 0.036012, 0) -bones/50/rotation = Quaternion(0.344364, -0.00251827, -0.0362247, 0.938134) +bones/50/rotation = Quaternion(0.319023, -0.00234929, -0.0340794, 0.947131) bones/50/scale = Vector3(1, 1, 1) bones/51/name = "RightHandRing3" bones/51/parent = 50 @@ -7923,14 +7934,14 @@ bones/53/parent = 36 bones/53/rest = Transform3D(0.989897, 0.0602255, 0.128364, 0.133612, -0.0931972, -0.986642, -0.0474579, 0.993824, -0.100302, -0.047258, 0.109082, 0.00226358) bones/53/enabled = true bones/53/position = Vector3(-0.047258, 0.109082, 0.00226358) -bones/53/rotation = Quaternion(0.207032, -0.0111325, 0.0919299, 0.973942) +bones/53/rotation = Quaternion(0.207886, -0.0111429, 0.0918245, 0.97377) bones/53/scale = Vector3(1, 1, 1) bones/54/name = "RightHandPinky2" bones/54/parent = 53 bones/54/rest = Transform3D(0.983236, -0.118306, 0.138749, 0.122507, -0.134994, -0.983244, 0.135054, 0.983758, -0.118237, -2.98023e-08, 0.0413665, 4.24334e-08) bones/54/enabled = true bones/54/position = Vector3(-2.98023e-08, 0.0413665, 4.24334e-08) -bones/54/rotation = Quaternion(0.372737, -0.0132658, -0.0705749, 0.925154) +bones/54/rotation = Quaternion(0.347849, -0.0121362, -0.0689791, 0.934931) bones/54/scale = Vector3(1, 1, 1) bones/55/name = "RightHandPinky3" bones/55/parent = 54 @@ -7951,28 +7962,28 @@ bones/57/parent = 0 bones/57/rest = Transform3D(-0.919821, -0.336213, -0.202214, 0.264978, -0.912457, 0.311783, -0.289337, 0.233202, 0.928386, -0.0912445, -0.0665637, -0.000553781) bones/57/enabled = true bones/57/position = Vector3(-0.0912445, -0.0665637, -0.000553781) -bones/57/rotation = Quaternion(-0.12548, 0.00578503, 0.983219, 0.132295) +bones/57/rotation = Quaternion(-0.124341, 0.0264339, 0.983422, 0.12931) bones/57/scale = Vector3(1, 1, 1) bones/58/name = "RightLeg" bones/58/parent = 57 bones/58/rest = Transform3D(0.997811, 0.0392429, -0.0532304, 0.00932048, 0.713425, 0.70067, 0.0654722, -0.699632, 0.711497, 4.84288e-08, 0.405994, 2.6077e-08) bones/58/enabled = true bones/58/position = Vector3(4.84288e-08, 0.405994, 2.6077e-08) -bones/58/rotation = Quaternion(-0.282558, 0.0687973, -0.0171965, 0.956626) +bones/58/rotation = Quaternion(-0.30856, 0.0711031, -0.0192402, 0.948348) bones/58/scale = Vector3(1, 1, 1) bones/59/name = "RightFoot" bones/59/parent = 58 bones/59/rest = Transform3D(0.96994, -0.122934, 0.210008, 0.229929, 0.180407, -0.95634, 0.0796801, 0.975879, 0.20325, -1.02445e-08, 0.42099, 9.31323e-09) bones/59/enabled = true bones/59/position = Vector3(-1.02445e-08, 0.42099, 9.31323e-09) -bones/59/rotation = Quaternion(0.590601, 0.061974, 0.114623, 0.796373) +bones/59/rotation = Quaternion(0.598057, 0.0607321, 0.11183, 0.791286) bones/59/scale = Vector3(1, 1, 1) bones/60/name = "RightToeBase" bones/60/parent = 59 bones/60/rest = Transform3D(0.999367, 6.43255e-05, 0.0355612, 0.0227211, 0.768109, -0.639916, -0.027356, 0.640319, 0.767622, -5.51563e-09, 0.16432, -1.09159e-07) bones/60/enabled = true bones/60/position = Vector3(-5.51563e-09, 0.16432, -1.09159e-07) -bones/60/rotation = Quaternion(0.353617, 0.0202494, 0.00409101, 0.935162) +bones/60/rotation = Quaternion(0.354093, 0.0200057, 0.00419447, 0.934987) bones/60/scale = Vector3(1, 1, 1) bones/61/name = "RightToe_End" bones/61/parent = 60 @@ -7986,28 +7997,28 @@ bones/62/parent = 0 bones/62/rest = Transform3D(-0.893651, 0.403296, 0.196826, -0.227377, -0.785047, 0.576195, 0.386895, 0.470164, 0.793258, 0.0912445, -0.0665636, -0.000553777) bones/62/enabled = true bones/62/position = Vector3(0.0912445, -0.0665636, -0.000553777) -bones/62/rotation = Quaternion(0.079535, 0.206395, 0.969743, -0.103314) +bones/62/rotation = Quaternion(0.078004, 0.217307, 0.967221, -0.105715) bones/62/scale = Vector3(1, 1, 1) bones/63/name = "LeftLeg" bones/63/parent = 62 bones/63/rest = Transform3D(0.99576, 0.0029921, 0.0919402, -0.056273, 0.810456, 0.583091, -0.0727688, -0.585792, 0.807188, 5.12227e-08, 0.405994, -2.04891e-08) bones/63/enabled = true bones/63/position = Vector3(5.12227e-08, 0.405994, -2.04891e-08) -bones/63/rotation = Quaternion(-0.310927, 0.116805, -0.0370301, 0.942502) +bones/63/rotation = Quaternion(-0.310851, 0.119773, -0.038572, 0.942093) bones/63/scale = Vector3(1, 1, 1) bones/64/name = "LeftFoot" bones/64/parent = 63 bones/64/rest = Transform3D(0.977802, 0.128039, -0.165856, -0.209522, 0.59104, -0.778956, -0.00170929, 0.796415, 0.604748, -2.04891e-08, 0.42099, 6.98492e-09) bones/64/enabled = true bones/64/position = Vector3(-2.04891e-08, 0.42099, 6.98492e-09) -bones/64/rotation = Quaternion(0.492167, -0.0208314, -0.037477, 0.869444) +bones/64/rotation = Quaternion(0.485644, -0.0222073, -0.0402602, 0.872947) bones/64/scale = Vector3(1, 1, 1) bones/65/name = "LeftToeBase" bones/65/parent = 64 bones/65/rest = Transform3D(0.999367, -0.000945242, -0.0355486, -0.0227206, 0.752033, -0.658734, 0.0273564, 0.659125, 0.751536, 3.66616e-08, 0.16432, -1.10293e-07) bones/65/enabled = true bones/65/position = Vector3(3.66616e-08, 0.16432, -1.10293e-07) -bones/65/rotation = Quaternion(0.360041, -0.000812983, -0.0304091, 0.93244) +bones/65/rotation = Quaternion(0.357758, 0.0018001, -0.028847, 0.933367) bones/65/scale = Vector3(1, 1, 1) bones/66/name = "LeftToe_End" bones/66/parent = 65 @@ -8026,7 +8037,7 @@ mesh = SubResource("ArrayMesh_ludfp") skin = SubResource("Skin_0b2ap") [node name="BoneAttachment3D" type="BoneAttachment3D" parent="Armature/Skeleton3D"] -transform = Transform3D(0.996372, -0.083364, 0.017149, 0.0798887, 0.846582, -0.526229, 0.0293506, 0.525689, 0.85017, -0.016959, 1.50103, 0.114791) +transform = Transform3D(0.997534, -0.0685353, 0.0151077, 0.0649211, 0.819374, -0.569571, 0.0266569, 0.569148, 0.821803, -0.0169638, 1.49564, 0.110585) bone_name = "Head" bone_idx = 5 @@ -8035,15 +8046,17 @@ libraries = { "": SubResource("AnimationLibrary_ovx1j") } -[node name="AnimationTree" type="AnimationTree" parent="."] +[node name="AnimationTree" type="AnimationTree" parent="." node_paths=PackedStringArray("movement_script")] tree_root = SubResource("AnimationNodeBlendTree_vhngy") anim_player = NodePath("../AnimationPlayer") active = true -parameters/TimeSeek/seek_request = -1.0 +parameters/InAir/blend_amount = 0.0 +parameters/StopSeek/seek_request = -1.0 parameters/Transition/current_state = "Idle" parameters/Transition/transition_request = "" parameters/Transition/current_index = 0 script = ExtResource("2_b8w6u") +movement_script = NodePath("../PlayerGameplayComponent") [node name="CameraComponent" type="Node" parent="." node_paths=PackedStringArray("networking", "SpringArm", "Camera", "PlayerRef", "first_person_camera_bone")] script = ExtResource("3_lou0l") @@ -8068,16 +8081,12 @@ target_position = Vector3(0, 0, -10) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.912079, 0) shape = SubResource("CapsuleShape3D_bfs86") -[node name="PlayerController" type="Node" parent="." node_paths=PackedStringArray("character_component", "networking", "lock_system")] +[node name="PlayerController" type="Node" parent="." node_paths=PackedStringArray("character_component", "networking")] script = ExtResource("6_nwle3") OnePressJump = true UsingCrouchToggle = true character_component = NodePath("../PlayerGameplayComponent") networking = NodePath("../PlayerNetworkingComponent") -lock_system = NodePath("../LockSystem") - -[node name="LockSystem" type="Node" parent="."] -script = ExtResource("7_gldfq") [node name="PlayerNetworkingComponent" type="Node" parent="."] script = ExtResource("6_uat01") @@ -8130,6 +8139,7 @@ cooldown_unfill_exaust_color = Color(0.705882, 0, 0, 0.478431) attribute_name = "stamina" [node name="Status" type="Control" parent="."] +visible = false layout_mode = 3 anchors_preset = 0 offset_right = 40.0 diff --git a/client/project.godot b/client/project.godot index 64b9851..6828c92 100644 --- a/client/project.godot +++ b/client/project.godot @@ -20,6 +20,10 @@ config/icon="res://icon.svg" Multi="*res://scenes/multi.gd" Global="*res://player/Global.gd" +[display] + +window/subwindows/embed_subwindows=false + [input] ui_left={ @@ -69,7 +73,8 @@ ui_sprint={ } ui_jump={ "deadzone": 0.5, -"events": [] +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":32,"physical_keycode":0,"key_label":0,"unicode":32,"echo":false,"script":null) +] } ui_interaction={ "deadzone": 0.5, @@ -81,7 +86,8 @@ ui_crouch={ } ui_switch_camera_view={ "deadzone": 0.5, -"events": [] +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":86,"physical_keycode":0,"key_label":0,"unicode":118,"echo":false,"script":null) +] } ui_ragdoll={ "deadzone": 0.5, @@ -104,6 +110,11 @@ ui_quit={ "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"echo":false,"script":null) ] } +ui_debug={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194343,"key_label":0,"unicode":0,"echo":false,"script":null) +] +} [rendering] diff --git a/client/scenes/DebugWindow.gd b/client/scenes/DebugWindow.gd index 11bd378..2a4d38d 100644 --- a/client/scenes/DebugWindow.gd +++ b/client/scenes/DebugWindow.gd @@ -1,11 +1,39 @@ extends Window +@export var node_players : Node = null: + set(value): + node_players = value + + +@export var node_me : Node = null: + set(value): + node_me = value + + # Called when the node enters the scene tree for the first time. func _ready(): pass # Replace with function body. # Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta): - pass +func _process(_delta): + if node_players: + $TabContainer/Perso/VBoxContainer/HBoxContainer/Count.set_text(str(node_players.get_child_count())) + $TabContainer/Perso/VBoxContainer/HBoxContainer2/Id.set_text(str(Multi.get_id())) + if node_players.get_child_count() > 0: + $TabContainer/Network/VBoxContainer/players/player0.set_text(str(node_players.get_child(0).get_global_position())) + print(str(node_players.get_child(0).get_global_position())) + if node_me: + $TabContainer/Network/VBoxContainer/me/me.set_text(str(node_me.get_child(0).get_global_position())) + var tmp:String = "" + tmp += "Anim: " + str(node_me.get_child(0).get_animation()) + tmp += "\nGait: " + node_me.get_child(0).get_gait() + tmp += "\nStance: " + node_me.get_child(0).get_stance() + tmp += "\nRotation: " + node_me.get_child(0).get_rotation_mode() + tmp += "\nMovement: " + node_me.get_child(0).get_movement_state() + $TabContainer/Network/VBoxContainer/state/state.set_text(tmp) + + +func _on_close_requested(): + hide() diff --git a/client/scenes/DebugWindow.tscn b/client/scenes/DebugWindow.tscn index afbb746..543dbd7 100644 --- a/client/scenes/DebugWindow.tscn +++ b/client/scenes/DebugWindow.tscn @@ -17,6 +17,7 @@ grow_horizontal = 2 grow_vertical = 2 [node name="Perso" type="TabBar" parent="TabContainer"] +visible = false layout_mode = 2 [node name="VBoxContainer" type="VBoxContainer" parent="TabContainer/Perso"] @@ -38,7 +39,7 @@ text = "Count" [node name="Count" type="Label" parent="TabContainer/Perso/VBoxContainer/HBoxContainer"] layout_mode = 2 size_flags_horizontal = 3 -text = "0" +text = "-" [node name="HBoxContainer2" type="HBoxContainer" parent="TabContainer/Perso/VBoxContainer"] layout_mode = 2 @@ -54,7 +55,6 @@ size_flags_horizontal = 3 text = "0" [node name="Network" type="TabBar" parent="TabContainer"] -visible = false layout_mode = 2 [node name="VBoxContainer" type="VBoxContainer" parent="TabContainer/Network"] @@ -64,3 +64,43 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 + +[node name="players" type="HBoxContainer" parent="TabContainer/Network/VBoxContainer"] +layout_mode = 2 + +[node name="Label" type="Label" parent="TabContainer/Network/VBoxContainer/players"] +layout_mode = 2 +text = "2nd player:" + +[node name="player0" type="Label" parent="TabContainer/Network/VBoxContainer/players"] +layout_mode = 2 +size_flags_vertical = 1 + +[node name="me" type="HBoxContainer" parent="TabContainer/Network/VBoxContainer"] +layout_mode = 2 + +[node name="Label" type="Label" parent="TabContainer/Network/VBoxContainer/me"] +layout_mode = 2 +text = "me:" + +[node name="me" type="Label" parent="TabContainer/Network/VBoxContainer/me"] +layout_mode = 2 +size_flags_vertical = 1 +text = "me" + +[node name="state" type="HBoxContainer" parent="TabContainer/Network/VBoxContainer"] +layout_mode = 2 + +[node name="Label" type="Label" parent="TabContainer/Network/VBoxContainer/state"] +layout_mode = 2 +text = "state:" + +[node name="state" type="Label" parent="TabContainer/Network/VBoxContainer/state"] +layout_mode = 2 +text = "anim" + +[node name="HBoxContainer" type="HBoxContainer" parent="TabContainer/Network/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 + +[connection signal="close_requested" from="." to="." method="_on_close_requested"] diff --git a/client/scenes/Window.gd b/client/scenes/Window.gd index 9ce97ad..d66f589 100644 --- a/client/scenes/Window.gd +++ b/client/scenes/Window.gd @@ -50,12 +50,12 @@ func _on_focus_exited(): func _on_mouse_entered(): focus_ok = true - self.get_parent().CharacterBody3D.disabled = true + #self.get_parent().CharacterBody3D.disabled = true func _on_mouse_exited(): focus_ok = false - self.get_parent().CharacterBody3D.disabled = false + #self.get_parent().CharacterBody3D.disabled = false func open_windows(): focus_ok = false diff --git a/client/scenes/main.gd b/client/scenes/main.gd index f04c965..02c0e4b 100644 --- a/client/scenes/main.gd +++ b/client/scenes/main.gd @@ -16,9 +16,9 @@ var player_name: String #const PLAYER = preload("res://player/character.tscn") const player_path:String = "res://player/character.tscn" @export var PlayerCharacter = preload(player_path) -#@export var debug_window: PackedScene +@export var debug_window: PackedScene -@onready var _MainWindow: Window = get_window() +#@onready var _MainWindow: Window = get_window() func _ready(): _on_connexion_updated(Multi.Connexion.NONE) @@ -29,13 +29,13 @@ func _ready(): $PlayerSpawnLocation.add_child(p) $PlayerSpawnLocation.set_visible(false) p.set_otherplayer(false) - Multi.set_player_position($PlayerSpawnLocation.get_child(0)) + #Multi.set_player_position($PlayerSpawnLocation.get_child(0)) + Multi.set_player_position($PlayerSpawnLocation) Multi.connexion_updated.connect(_on_connexion_updated) Multi.update_my_position.connect(_on_update_me) Multi.update_player_position.connect(_on_update_player) Multi.remove_player.connect(_on_remove_player) - #_MainWindow.gui_embed_subwindows = false # Make subwindows actual system windows <- VERY IMPORTANT - + #$Window.world_2d = _MainWindow.world_2d func create_view_window(): pass @@ -71,10 +71,10 @@ func _on_connexion_updated(new_state:Multi.Connexion): $Panel.show() elif new_state == Multi.Connexion.CONNECTED: $Panel.hide() - $PlayerSpawnLocation.set_visible(true) $PlayerSpawnLocation.get_child(0).set_current_camera() $PlayerSpawnLocation.get_child(0).set_name(str(Multi.get_id())) $PlayerSpawnLocation.get_child(0).set_id(Multi.get_id()) + $PlayerSpawnLocation.set_visible(true) $CameraStarting.set_current(false) else: $CameraStarting.set_current(true) @@ -107,6 +107,8 @@ func _on_update_player(id:int, pos:Vector3): child2.set_global_position(pos) else: print("Update player : ", id, " ", pos) + print(pos) + #pos.y += 10.0 child.set_global_position(pos) #child.set_visible(true) @@ -136,16 +138,21 @@ func _on_remove_player(id:int): # print("==========================") -func _process(delta): -# if $PlayerSpawnLocation: -# print(">", $PlayerSpawnLocation.get_global_position()) - pass +#func _process(delta): +## if $PlayerSpawnLocation: +## print(">", $PlayerSpawnLocation.get_global_position()) +# pass func _input(event): if event is InputEventKey: if event.is_action_pressed("ui_quit"): get_tree().quit() + elif event.is_action_pressed("ui_debug"): + var new_window: Window = debug_window.instantiate() + add_child(new_window) + new_window.node_players = $Players + new_window.node_me = $PlayerSpawnLocation func set_player_position(pos: Vector3): diff --git a/client/scenes/main.tscn b/client/scenes/main.tscn index 5f84746..cc6c626 100644 --- a/client/scenes/main.tscn +++ b/client/scenes/main.tscn @@ -1,11 +1,13 @@ -[gd_scene load_steps=10 format=3 uid="uid://bemavktwweaog"] +[gd_scene load_steps=11 format=3 uid="uid://bemavktwweaog"] [ext_resource type="Shader" path="res://scenes/main.gdshader" id="1_caff6"] [ext_resource type="Script" path="res://scenes/main.gd" id="1_ts8of"] +[ext_resource type="PackedScene" uid="uid://ddymq82ef22l2" path="res://scenes/DebugWindow.tscn" id="2_6hoce"] [ext_resource type="Script" path="res://scenes/Window.gd" id="3_uwnj8"] [sub_resource type="BoxShape3D" id="BoxShape3D_5dcgs"] -size = Vector3(1000, 1, 1000) +margin = 1.0 +size = Vector3(1000, 0, 1000) [sub_resource type="ShaderMaterial" id="ShaderMaterial_gypq5"] render_priority = 0 @@ -13,7 +15,7 @@ shader = ExtResource("1_caff6") [sub_resource type="BoxMesh" id="BoxMesh_fm2j6"] material = SubResource("ShaderMaterial_gypq5") -size = Vector3(1000, 1, 1000) +size = Vector3(1000, 0, 1000) [sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_0qg6h"] @@ -29,9 +31,9 @@ reflected_light_source = 2 [node name="main" type="Node3D"] script = ExtResource("1_ts8of") +debug_window = ExtResource("2_6hoce") [node name="ground" type="StaticBody3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0) [node name="CollisionShape3D" type="CollisionShape3D" parent="ground"] shape = SubResource("BoxShape3D_5dcgs") @@ -53,6 +55,7 @@ environment = SubResource("Environment_12j7q") title = "Connexion" initial_position = 1 size = Vector2i(300, 200) +always_on_top = true script = ExtResource("3_uwnj8") [node name="VBoxContainer" type="VBoxContainer" parent="Window"] diff --git a/start-bazar-client.sh b/start-bazar-client.sh index 7b6de37..40d5459 100755 --- a/start-bazar-client.sh +++ b/start-bazar-client.sh @@ -7,7 +7,7 @@ declare FORCE=0 declare IMPORT=0 declare ERASEIMPORT=0 declare WORKDIR="$(dirname $(readlink -f $0))" -declare GODOT_SRC="https://downloads.tuxfamily.org/godotengine/4.1.2/Godot_v4.1.2-stable_linux.x86_64.zip" +declare GODOT_SRC="https://downloads.tuxfamily.org/godotengine/4.1.3/Godot_v4.1.3-stable_linux.x86_64.zip" declare OUTZIP="$WORKDIR/$(basename $GODOT_SRC)" declare CLIENTDIR="$WORKDIR/client" declare OPTION=""