feat: implement core movement, combat, weapon management, and networking systems
This commit is contained in:
@@ -170,15 +170,16 @@ func update_state(state: String, speed: float, is_crouching: bool = false) -> vo
|
||||
current_state = "crouch"
|
||||
|
||||
var is_holding_weapon: bool = false
|
||||
var held_weapon_name: String = ""
|
||||
|
||||
func set_weapon(script_path: String) -> void:
|
||||
# Clear existing weapons from root_pivot
|
||||
for child in root_pivot.get_children():
|
||||
for child in lower_arm_r_pivot.get_children():
|
||||
if child.has_meta("is_third_person_weapon"):
|
||||
child.queue_free()
|
||||
|
||||
if script_path == "":
|
||||
is_holding_weapon = false
|
||||
held_weapon_name = ""
|
||||
return
|
||||
|
||||
is_holding_weapon = true
|
||||
@@ -190,6 +191,7 @@ func set_weapon(script_path: String) -> void:
|
||||
var w = script.new()
|
||||
w.name = "ThirdPersonWeapon"
|
||||
w.set_meta("is_third_person_weapon", true)
|
||||
held_weapon_name = w.get("weapon_name") if "weapon_name" in w else ""
|
||||
|
||||
# Connect to ready so we can override the weapon's own _ready() calls
|
||||
w.ready.connect(func():
|
||||
@@ -198,13 +200,13 @@ func set_weapon(script_path: String) -> void:
|
||||
if shadows_only:
|
||||
_set_shadows_recursive(w)
|
||||
|
||||
# Force position after the weapon's _build_model() sets it for 1st person
|
||||
w.position = Vector3(-0.15, 1.0, 0.4)
|
||||
w.rotation_degrees = Vector3(0, 180, 0)
|
||||
# Attach to hand (which is at y=-0.35 from elbow)
|
||||
w.position = Vector3(0.0, -0.35, 0.0)
|
||||
w.rotation_degrees = Vector3(-90, 0, 0)
|
||||
)
|
||||
|
||||
# Attach to root_pivot so it stays steady and points perfectly forward
|
||||
root_pivot.add_child(w)
|
||||
# Attach to right arm instead of root pivot
|
||||
lower_arm_r_pivot.add_child(w)
|
||||
|
||||
func _set_shadows_recursive(node: Node) -> void:
|
||||
if node is GeometryInstance3D:
|
||||
@@ -265,7 +267,7 @@ func _process(delta: float) -> void:
|
||||
t_calf_r_rot.x = 0.05
|
||||
|
||||
"crouch":
|
||||
t_root_pos.y = -0.5
|
||||
t_root_pos.y = -0.3
|
||||
# Thighs forward, calves back
|
||||
t_thigh_l_rot.x = -1.0
|
||||
t_thigh_r_rot.x = -1.0
|
||||
@@ -279,12 +281,12 @@ func _process(delta: float) -> void:
|
||||
|
||||
"slide":
|
||||
t_root_pos.y = -0.6
|
||||
t_root_rot.x = deg_to_rad(-45) # Lean back
|
||||
t_root_rot.x = deg_to_rad(-10) # Almost upright
|
||||
# Legs forward
|
||||
t_thigh_l_rot.x = deg_to_rad(-60)
|
||||
t_thigh_r_rot.x = deg_to_rad(-30)
|
||||
t_calf_l_rot.x = 0.1
|
||||
t_calf_r_rot.x = 0.1
|
||||
t_thigh_l_rot.x = deg_to_rad(-80)
|
||||
t_thigh_r_rot.x = deg_to_rad(-80)
|
||||
t_calf_l_rot.x = 0.0
|
||||
t_calf_r_rot.x = 0.0
|
||||
# Arms back
|
||||
t_upper_arm_l_rot.x = deg_to_rad(60)
|
||||
t_upper_arm_r_rot.x = deg_to_rad(60)
|
||||
@@ -342,7 +344,7 @@ func _process(delta: float) -> void:
|
||||
t_calf_r_rot.x = deg_to_rad(10)
|
||||
|
||||
"dash":
|
||||
t_root_rot.x = deg_to_rad(-70)
|
||||
t_root_rot.x = deg_to_rad(45)
|
||||
t_upper_arm_l_rot.x = deg_to_rad(-170)
|
||||
t_lower_arm_l_rot.x = 0.0
|
||||
t_upper_arm_r_rot.x = deg_to_rad(-170)
|
||||
@@ -365,17 +367,17 @@ func _process(delta: float) -> void:
|
||||
t_thigh_r_rot.x = deg_to_rad(10)
|
||||
t_calf_r_rot.x = 0.0
|
||||
|
||||
# Override right arm (and left) if holding a weapon
|
||||
if is_holding_weapon and current_state != "death":
|
||||
# Pose the right arm to look like it's holding the weapon handle
|
||||
t_upper_arm_r_rot.x = -0.6
|
||||
# Pose the right arm to look like it's holding the weapon handle straight out
|
||||
t_upper_arm_r_rot.x = -1.2
|
||||
t_upper_arm_r_rot.z = 0.15
|
||||
t_lower_arm_r_rot.x = -1.0
|
||||
t_lower_arm_r_rot.x = -0.2
|
||||
|
||||
# Pose the left arm to look like it's holding the foregrip
|
||||
t_upper_arm_l_rot.x = -0.5
|
||||
t_upper_arm_l_rot.z = -0.15
|
||||
t_lower_arm_l_rot.x = -1.1
|
||||
# If it's a two handed weapon, the left arm reaches over
|
||||
if held_weapon_name != "Knife":
|
||||
t_upper_arm_l_rot.x = -1.2
|
||||
t_upper_arm_l_rot.z = -0.15
|
||||
t_lower_arm_l_rot.x = -0.3
|
||||
|
||||
var lerp_speed = 40.0 * delta
|
||||
root_pivot.position = root_pivot.position.lerp(t_root_pos, lerp_speed)
|
||||
|
||||
Reference in New Issue
Block a user