planet_switcher.gd 847 B

12345678910111213141516171819202122232425262728293031323334
  1. extends Node
  2. # Declare member variables here. Examples:
  3. # var a = 2
  4. # var b = "text"
  5. var camera
  6. var camera_parent
  7. # Called when the node enters the scene tree for the first time.
  8. func _ready():
  9. camera = find_node("camera")
  10. camera_parent = get_node("planet1/planet")
  11. camera.get_parent().remove_child(camera)
  12. camera_parent.add_child(camera)
  13. pass # Replace with function body.
  14. func _on_ItemList_item_selected(index):
  15. if index == 0:
  16. camera_parent.remove_child(camera)
  17. camera_parent = get_node("Sun")
  18. camera_parent.add_child(camera)
  19. if index == 1:
  20. camera_parent.remove_child(camera)
  21. camera_parent = get_node("planet1/planet")
  22. camera_parent.add_child(camera)
  23. if index == 2:
  24. camera_parent.remove_child(camera)
  25. camera_parent = get_node("planet2/planet")
  26. camera_parent.add_child(camera)
  27. pass # Replace with function body.