admin管理员组文章数量:1357276
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.
本文标签: godotHow to change the scene when a player collides with Node 2DStack Overflow
版权声明:本文标题:godot - How to change the scene when a player collides with Node 2D? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744074922a2586567.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
print(body.name)
to the line beforeif body.name ==...
. – Jonathan F. Commented Mar 28 at 13:26