Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | RockZombie4 |
I am developing a game which has moving obstacles controlled by the tween node. They have collision boxes, and detect collisions with the player. I have a scene which has the obstacles and the player, but I also have another scene which is the level menu. When I click on a level, it should take me to a scene which contains the level requested. I have done all that already, but I have a problem. If I run the level scene directly and test collision, all works well. But when I run the level through the menu and test collision, when I hit the obstacle, the game instantly crashes with an error:
E 0:00:05.818 get_node: (Node not found: "/root/Node2D/DiePanel" (absolute path attempted from "/root/@Node2D@2/StaticBody2D").)
<C++ Error> Condition "!node" is true. Returned: nullptr
<C++ Source> scene/main/node.cpp:1322 @ get_node()
<Stack Trace> StaticBody2D.gd:28 @ _on_Area2D_area_entered()
This is my code for the current only moving obstacle in the game:
# extends StaticBody2D
extends Area2D
func _ready():
$Tween.interpolate_property(self, "position", Vector2(0, 0), Vector2(100, 0), 1, Tween.TRANS_BACK, Tween.EASE_IN_OUT)
$Tween.start()
func _on_Tween_tween_all_completed():
$Tween2.interpolate_property(self, "position", Vector2(100, 0), Vector2(100, -100), 1, Tween.TRANS_BACK, Tween.EASE_IN_OUT)
$Tween2.start()
func _on_Tween2_tween_all_completed():
$Tween3.interpolate_property(self, "position", Vector2(100, -100), Vector2(0, -100), 1, Tween.TRANS_BACK, Tween.EASE_IN_OUT)
$Tween3.start()
func _on_Tween3_tween_all_completed():
$Tween4.interpolate_property(self, "position", Vector2(0, -100), Vector2(0, 0), 1, Tween.TRANS_BACK, Tween.EASE_IN_OUT)
$Tween4.start()
# NOT PART OF TWEENS
func _on_Area2D_area_entered(area):
var DiePanel = get_node("/root/Node2D/DiePanel")
DiePanel.show()
get_tree().paused = true
print("test")
Thanks.