Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | fefe_enn0 |
hello everyone
i have one problem in my game
when i want to send the player from area 1 to area 2 it is did not work
first when i write my code that i want it to send the player from area 1 to area 2 or to another position
it is dose not work i get many problem sometimes the said the
E 0:00:17.512 get_node: (Node not found: "Player" (relative to "/root/Root/Area2D").)
<C++ Error> Method failed. Returning: nullptr
<C++ Source> scene/main/node.cpp:1465 @ get_node()
<Stack Trace> Area2D.gd:7 @ _on_Area2D_body_entered()
or errors like that that saying the player is not relative or not found
my code is like this
extends Node2D
var new_position = Vector2(-238, -379)
func _on_Area2D_body_entered(body):
if body.name == "Player":
$Player.set_position(new_position)
so if there another way to send player from area 1 to area 2 or from position to another one please tell me
and with all my thank full for any helps i get
$Player.set_position(new_position)
This means the player is a child of this node; it’s syntactic sugar for get_node
(doc). What you probably mean to do is:
body.set_position(new_position)
spaceyjase | 2023-05-22 10:31
oh i will try it thanks
fefe_enn0 | 2023-05-22 14:12