How do you move if pos() don't work in 3.0 anymore?

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

So I’m working on this course from udemy and I decided to be brave and try to do it in 3.0 but can’t get this part to work. I’ve looked everywhere and just can’t figure this out.

extends Node2D


export var vel = -150

func _ready():
	set_process(true)
	
func _process(delta):
	set_pos(get_pos() + Vector2(vel * delta, 0))
:bust_in_silhouette: Reply From: kidscancode

In 3.0, your code would look like this:

extends Node2D

export var vel = -150

func _process(delta):
    position += Vector2(vel, 0) * delta

Note a couple of changes:

  • pos/rot/etc are renamed to position, rotation, etc
  • get/set methods are replaced by member variable access
  • You no longer need to set process or input true by default