Why is set_pos(get_pos()) not working here?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Robster
:warning: Old Version Published before Godot 3 was released.

I’m following the flappy bird tutorial again to tune my skills some more. I’m on Tutorial 3. Spawning. On the spawner_pipe.gd I have the following and the line:

new_pipe.set_pos(get_pos())

is giving the following error:
Invalid call. Nonexistent function 'get_pos' in base 'Node (spawner_pipe.gd)'.

When I type set_pos() I get auto complete happening but when I type get_pos() I get no auto complete. Strange.

Here is the full code so far:

#script: spawner_pipe

extends Node

const scn_pipe = preload("res://scenes/pipe.tscn")

func _ready():
	spawn_pipe()
	pass

func spawn_pipe():
	var new_pipe = scn_pipe.instance()
	new_pipe.set_pos(get_pos())
	get_node("container").add_child(new_pipe)
	pass

func go_next_pos():
	pass

Cancel that! I had the script attached to the wrong Node. It was a Node, not a Node2d. Hopefully this helps someone in the future.

Robster | 2017-01-21 00:27

:bust_in_silhouette: Reply From: Nutr1z

Hi,

The answer is simple,Node don’t have a position, so get_pos() don’t existe. Try to extend from Node2D to fix your problem.

Thank you and so sorry for the late reply. I appreciate your help and again, I must have been on another planet not to thank you.

Robster | 2017-12-21 22:43