fix missing character model

This commit is contained in:
2025-02-20 11:29:03 +08:00
parent f9e0c81aee
commit 276aa439ab
2 changed files with 125 additions and 29 deletions
+33 -1
View File
@@ -40,9 +40,13 @@ var rotation_speed: float = 10.0
var highlighted_cells = []
func _ready():
# Ensure name is set first
name = str(get_multiplayer_authority())
$Name.text = str(name)
# Wait briefly to ensure proper scene setup
await get_tree().create_timer(0.1).timeout
# More robust way to get the main scene
var main_scene = get_tree().get_root().get_node_or_null("Main")
if not main_scene:
@@ -100,7 +104,15 @@ func _ready():
#append_random_goals()
playerboard.resize(25)
playerboard.fill(-1)
# Ensure proper initial positioning
global_position = Vector3(
current_position.x * cell_size.x + cell_size.x * 0.5,
1.0,
current_position.y * cell_size.z + cell_size.z * 0.5
)
if is_multiplayer_authority():
rpc("sync_position", current_position)
@rpc("any_peer", "call_local")
func sync_bot_status(is_bot_status: bool):
@@ -1041,3 +1053,23 @@ func bot_arrange_item(from_slot: int, to_slot: int):
has_performed_action = true
action_points -= 2
_after_action_completed()
func update_visual_position():
# Ensure proper grid-aligned positioning
global_position = Vector3(
current_position.x * cell_size.x + cell_size.x * 0.5,
1.0,
current_position.y * cell_size.z + cell_size.z * 0.5
)
if is_multiplayer_authority():
rpc("sync_position", current_position)
@rpc("any_peer", "call_local")
func sync_position(pos: Vector2):
current_position = pos
# Ensure proper grid-aligned positioning
global_position = Vector3(
current_position.x * cell_size.x + cell_size.x * 0.5,
1.0,
current_position.y * cell_size.z + cell_size.z * 0.5
)