feat: implement modular character skinning system with procedural and imported model support
This commit is contained in:
@@ -31,6 +31,7 @@ func _build_geometry() -> void:
|
||||
|
||||
func _spawn_player(pid: int) -> CharacterBody3D:
|
||||
var player = super._spawn_player(pid)
|
||||
player.add_to_group("players")
|
||||
player.position = Vector3(randf_range(-2, 2), 1, 50 + randf_range(-2, 2))
|
||||
# Looking at (0,1,0) from (0,1,50) is facing straight down the -Z axis, which is rotation = 0,0,0
|
||||
player.rotation = Vector3.ZERO
|
||||
|
||||
@@ -289,6 +289,7 @@ func _build_lighting() -> void:
|
||||
func _spawn_player(pid: int) -> CharacterBody3D:
|
||||
var player := CharacterBody3D.new()
|
||||
player.name = str(pid)
|
||||
player.add_to_group("players")
|
||||
player.set_multiplayer_authority(pid)
|
||||
|
||||
# Use a slightly random spawn position to avoid exact overlapping
|
||||
@@ -326,6 +327,7 @@ func _spawn_player(pid: int) -> CharacterBody3D:
|
||||
client_rep_config.add_property(":synced_loadout_ready")
|
||||
client_rep_config.add_property(":synced_is_targeting")
|
||||
client_rep_config.add_property(":synced_homing_target_pos")
|
||||
client_rep_config.add_property(":synced_skin_id")
|
||||
client_sync.replication_config = client_rep_config
|
||||
player.add_child(client_sync)
|
||||
|
||||
@@ -346,7 +348,11 @@ func _spawn_player(pid: int) -> CharacterBody3D:
|
||||
# Humanoid Model for Player (Shadows only locally, visible to others)
|
||||
var humanoid = load("res://characters/humanoid_model.gd").new()
|
||||
humanoid.name = "HumanoidModel"
|
||||
humanoid.color = Color(0.2, 0.4, 0.8) # Blueish for player
|
||||
var skin_mgr = get_node_or_null("/root/SkinManager")
|
||||
if skin_mgr and pid == multiplayer.get_unique_id():
|
||||
humanoid.skin = skin_mgr.get_player_skin()
|
||||
else:
|
||||
humanoid.skin = skin_mgr.get_skin("default") if skin_mgr else null
|
||||
humanoid.shadows_only = (pid == multiplayer.get_unique_id())
|
||||
humanoid.position = Vector3(0, -0.9, 0) # Offset from center to feet
|
||||
player.add_child(humanoid)
|
||||
|
||||
Reference in New Issue
Block a user