Topic was automatically imported from the old Question2Answer platform.
Asked By
abbos
Hello I’m making a simple game, I wrote the code, now I have to use move to get the car moving (I saw some tutorials)
But move is not just move_child, move_toward, do you know which one to use and what should I pass on to it?
Please comment
Hi. There are many different ways to move (or animate) a node.
Which function to use depends on which type of node you want to move and how you want to move it.
Anyway, there is a general simple direct way to move any node, and that is by changing the position property of the node directly, which is quite helpful in many situations.
Example:
onready var myCar = get_node("The Car")
func teleport():
myCar.position.x = 100
myCar.position.y = 200
#Above directly changes the position of myCar node to the coord (100, 200)
func _process(delta):
myCar.position.x += 1
#Slowly moves the car towards the right side
If you don’t use provided functions to move like here changing the position property, a function of your own is recommened. (For future convenience) Example: