Skip to content

Commit

Permalink
Prefer using get_node() directly instead of get_root()
Browse files Browse the repository at this point in the history
Closes #32.
  • Loading branch information
bdero committed Jun 14, 2016
1 parent 5f81cc7 commit 10426e5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
Binary file modified scenes/main.scn
Binary file not shown.
5 changes: 3 additions & 2 deletions scripts/globals.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var score = 0
var time = 0
var rings = 0

var main_scene
var camera
var fade

Expand All @@ -22,7 +23,7 @@ func load_scene(scene_name):
return ResourceLoader.load("res://scenes/" + scene_name + ".scn")

func _ready():
var main_scene = get_tree().get_root().get_node("main")
main_scene = get_node("/root/main")

camera = load_scene("camera").instance()
main_scene.add_child(camera)
Expand Down Expand Up @@ -106,7 +107,7 @@ func set_scene(scene):
# Create an instance of our scene
level = s.instance()
# Add scene to main
get_tree().get_root().get_node("main/scenes").add_child(level)
main_scene.get_node("scenes").add_child(level)

func is_character(body):
return body == character
2 changes: 1 addition & 1 deletion scripts/player/cam_base.gd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var velocity = Vector3(0, 0, 0)
func _ready():
cam_pitch = get_node("cam_pitch")
cam_pod = cam_pitch.get_node("cam/cam_pod")
character = get_parent().get_node("character")
character = get_node("../character")
set_process_input(true)
set_process(true)

Expand Down
4 changes: 2 additions & 2 deletions scripts/player/character.gd
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ var on_ground = false
var jump_held = false

func _ready():
camera = get_tree().get_root().get_node("globals").camera
camera = globals.camera
model = get_node("model")
animations = model.get_node("AnimationPlayer")
air_timer = get_parent().get_node("air_timer")
air_timer = get_node("../air_timer")
jump_timer = get_node("../jump_timer")
set_fixed_process(true)

Expand Down

0 comments on commit 10426e5

Please sign in to comment.