Set_pos() & get_pos()

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

i was following a toutorial on youtube and i get stuck at the set and get_pos() proplem
i get Error msg

invalid call. nonexistance function ‘get_pos’ in base ‘spirite’.

i just need the answer or if there is an equivelent function that have the same purpose

i need to move the object from one point to another using the arrow keys it is a ping bong game and here is a code sample

func _ready():
pass # Replace with function body.
func _process(delta):
var LeftPos = get_node("Left Player").get_pos()
if (Input.is_action_pressed("LeftPlayer UP")):
	LeftPos.y += -padspeed * delta
if (Input.is_action_pressed("LeftPlayer Down")):
	LeftPos.Y += padspeed * delta
get_node("Left Player").set_pos()
:bust_in_silhouette: Reply From: kidscancode

You’re looking at a very old tutorial, referring to Godot ver < 3.0.

In 3.0, you don’t need to get/set position, you just use the position property like you’d use any other class variable.

So, to set the “Left Player” node’s position:

get_nod("Left Player").position = Vector2(x, y)

Also, you no longer need to set_process(true).

I would highly recommend switching to a more up-to-date tutorial; at least one from the last few years since the release of Godot 3.0.