Map changinbg
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user