Skip to content

Instantly share code, notes, and snippets.

@FEDE0D
Last active June 20, 2017 13:53
Show Gist options
  • Save FEDE0D/ee24480de4d8fd31efa0 to your computer and use it in GitHub Desktop.
Save FEDE0D/ee24480de4d8fd31efa0 to your computer and use it in GitHub Desktop.
# You can do this
func _fixed_process(delta):
var pos_a = get_node("body_a").get_global_pos()
var pos_b = get_node("body_b").get_global_pos()
# lets say you want to move the body_a to body_b
var new_pos = pos_a.linear_interpolate(pos_b, delta)
get_node("body_a").set_global_pos(new_pos)
# linear_interpolate receives the final position and a value between 0 and 1.
# If its 0 :> returns the starting pos
# If its 1 :> returns the final pos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment