e2.5 Save and Export
Closed this issue · 2 comments
tylerecouture commented
Set parent
So node created in tool appear int he scene tree
- Obstacle and Ground
add_child(new_obstacle)
new_obstacle.set_owner(self) # after add_child
Save the scene as a resource
export var scene_name = "GeneratedScene"
export var save = false setget set_save
func _ready():
generate_map()
func set_save(new_val):
"Saving the scene"
save_scene()
# ...
func save_scene():
var packed_scene = PackedScene.new()
packed_scene.pack(self)
var scene_resource_path = "%s.tscn" % scene_name
print(scene_resource_path)
ResourceSaver.save(scene_resource_path, packed_scene)
tylerecouture commented
Navigation
-
add_nav
to the map gen method - create Navigation node, NavigationMeshInstance, and navmesh
# add ground and obstacle as children of the nav mesh isntance
var navmesh_instance: NavigationMeshInstance
...
func add_nav():
var nav := Navigation.new()
add_child(nav)
nav.set_owner(self)
navmesh_instance = NavigationMeshInstance.new()
navmesh_instance.navmesh = NavigationMesh.new()
nav.add_child(navmesh_instance_node)
navmesh_instance.set_owner(self)
tylerecouture commented
- Change ground and obstacle parent (still owned by scene root node)
navmesh_instance.add_child(ground)
ground.set_owner(self)