The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

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
in Engine by (824 points)

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.

1 Answer

+1 vote
Best answer

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.

by (370 points)
selected by

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.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.