Topic was automatically imported from the old Question2Answer platform.
Asked By
Sreenington
extends Node2D
onready var PLAYER = preload("res://PlayerFile/Player.tscn")
func _on_ToHallway_body_entered(body):
if body.name == "Player":
SceneChanger.change_scene("res://WorldFile/World.scn")
var player = PLAYER.instance()
get_node("YSort").add_child(player)
player.set_pos(100,100)
Im trying to add the player scene to another world but the game crashes and shows the following error message:
“Invalid call. Nonexistent function ‘set_pos’ in base ‘KinematicBody2D (Player.gd)’.”
The scene loads if I remove the last line of code but my goal is to set the player.tscn’s location to a certain coordinate on the screen, but the game crashes. I tried to make a function set_pos which takes in 2 variables(x, y) but the error message still persists. How can I go about this?