set_position command is making an error

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

Hello everyone,

I’m super new to Godot and I’m trying to follow a simple tutorial on YouTube. Since the tutorial is from Godot 2.0 and I’m using the recent version I’m having some issues.

The error message is as follows:
“Invalid call to function ‘set_position’ in base ‘Sprite (flare.gd)’. Expected 1 arguments.”

My laser script:
enter image description here

My flare script:enter image description here

Please help me!

:bust_in_silhouette: Reply From: kidscancode

First of all, why not use a tutorial that’s made for the version you’re using?

Using code from pre-3.0 requires many changes. As a beginner, you’re not going to know how to make those changes.

For example, the position property is a Vector2. That means that set_position() takes one argument, a vector, not two, which is what you’ve written: set_position(get_position().x, get_position().y).

That code could read

flare.set_position(get_position())

But post Godot-3.0 direct property access was added (and greatly simplifies code), so you’d write

flare.position = position

Again, I’d strongly advise avoiding outdated tutorials when you’re trying to learn the engine. There will be many things you just wind up learning to do the wrong way.