0 votes

I have the following line in my code I'm trying to use to add a node to a Node2D base node within my game

var paddle_one_node = paddle_one_scene.instance()
paddle_one_node.set_name("PaddleOne")
paddle_one_node.set_pos(Vector2(25, 300))
add_child(paddle_one_node)

I get an error, however, whenever I load the scene stating that set_pos() is a nonexisting function within the KinematicBody2D class. How do I set the position of this node? I'm new to this.

in Engine by (23 points)
retagged by

You need to provide more information. What is the "paddleonescene" and how is it loaded? Are you by any chance using Godot 3.0?

What kind of node is the root of the scene paddle_one?.

replace the set_pos line with:

   paddle_one_node.position = Vector2(25,300)

that is because in godot 3 they replaced the setpos and getpos with position, giving you instant access to the variable itself

I am using Godot 3 right now (Not Sure the date on this one) and here is the code I used to load the scene.

var paddle_one_scene = load(global.game.player_one_paddle)

Oh ok. Thanks! Didn't realized they changed that in Godot 3.

Please log in or register to answer this question.

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 webmaster@godotengine.org with your username.