I need to make it so that when the player collides with an object, the scene changes. But nothing happens during collision. Could you please tell me how to solve this problem?
extends Node2D
func _on_body_entered(body):
if body.name == "Player":
get_tree().change_scene_to_file("res://level1.tscn")
Here's a screenshot
I need to make it so that when the player collides with an object, the scene changes. But nothing happens during collision. Could you please tell me how to solve this problem?
extends Node2D
func _on_body_entered(body):
if body.name == "Player":
get_tree().change_scene_to_file("res://level1.tscn")
Here's a screenshot
Share Improve this question asked Mar 27 at 18:02 Sin nombreSin nombre 92 bronze badges 3 |1 Answer
Reset to default 0I think I know the problem. Select the detector object (object that sends the signal) in your node tree. Click on Node, and you will see the options Signals and Groups. Click Signals, and you will see the list of signals. Double click any of them to link it to your script.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744074922a4554221.html
print(body.name)
to the line beforeif body.name ==...
. – Jonathan F. Commented Mar 28 at 13:26