the method "get_global_pos" isn't declared in the current class.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Bruh

Help me plz! The method “get_global_pos” isn’t declared in the current class

extends Position2D

export (PackedScene) var spawnScene
onready var spawnReference = load (spawnScene.get_path())

export (NodePath) var timerPath
onready var timerNode = get_node(timerPath)

export (float) var minWaitTime
export (float) var maxWaitTime

func _on_Timer_timeout() -> void:
	var spawnInstance = spawnReference.instance()
	
	get_parent().add_child(spawnInstance)
	spawnInstance.set_global_pos(get_global_pos())
	
	timerNode.set_wait_time(rand_range(minWaitTime, maxWaitTime))
	timerNode.start()
:bust_in_silhouette: Reply From: kidscancode

Note: I edited your post to fix the code formatting. Please use the correct formatting so that your posts are readable.

Are you looking at a really old tutorial? get_global_pos() has not been valid since Godot 3.0 came out. You also don’t need to use get/set anymore.

spawnInstance.set_global_pos(get_global_pos())

Would now be written

spawnInstance.global_position = global_position