Map changinbg

This commit is contained in:
2025-07-04 15:02:41 -05:00
parent 7ae9d534ab
commit 29ebb68215
14 changed files with 192 additions and 39 deletions

View File

@@ -6,5 +6,22 @@ func _enter_tree() -> void:
func _exit_tree() -> void:
OVERWORLD.mapChanged.disconnect(onMapChanged)
func onMapChanged() -> void:
pass
func onMapChanged(newMap:PackedScene, playerDestinationNodeName:String) -> void:
print("New map time.")
var map = $Map
for childScene in map.get_children():
map.remove_child(childScene)
var newMapInstance = newMap.instantiate()
map.add_child(newMapInstance)
# Find Player.
var player = newMapInstance.get_node("Player")
var destNode = newMapInstance.get_node(playerDestinationNodeName)
if player && player is Player && destNode:
player.global_position = destNode.global_position
player.global_rotation.y = destNode.global_rotation.y
elif playerDestinationNodeName:
push_error("Player, or destination node not found in new map.")
pass