0 votes

What is the difference between:
$Node.position = Vector(a,b)

asked Jun 15 in Engine by igbow (32 points)

Both do the same don't worry about it.
I like using Node.position but that is just a preference.

1 Answer

+1 vote

Note: your use of set_position() is incorrect - it takes a single argument of a Vector2, not two arguments.

Using the position property is preferred. Properties will be suggested by autocomplete. set_ and get_ functions were used in Godot pre-3.0 - and still exist for compatibility - but they just make your code more verbose. Compare:

$Node2D.set_position($Node2D.get_position() + Vector2(100, 0))


$Node2D.position += Vector2(100, 0)
answered Jun 15 by kidscancode (11,450 points)
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 How to use this Q&A? before posting your first questions.