how do i make something change position

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

I want an animated sprite to change position and also want it’s offset to change position when an input is received. I do know about the offset and position functions but i still don’t understand how do i use them, can someone explain me

Depends where you are putting the script.

Lots of possibilities… here’s the basics:

2D movement overview — Godot Engine (stable) documentation in English

CassanovaWong | 2022-02-16 09:11

:bust_in_silhouette: Reply From: Major_Monkey_0720

I believe what you are trying to do is

if Input.is_action_pressed("input"):
     position.x += 10
     # or offset.x += 10
     # you may also do position -= 10 to have it move left
     # if you want to have the Y axis change, write position.y

Or if you want to directly set the nodes position, write

position = Vector2(x, y)
# x and y should be written as integers, or other variables/constants
# Vector2() is the data type for coordinates, or directions

I hope that helped
If you meant changing the position from within the animation, I recommend using the “AnimationPlayer” node. You can find more about that in the documentation.

that helped a lot, thanks

gm130993 | 2022-02-16 23:18