Topic was automatically imported from the old Question2Answer platform.
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
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.