Problem with moving platforms

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

I’m having a lot of issues getting moving platforms to work as intended. I have 3 moving platforms that together make up a line: Imgur: The magic of the Internet. They work fine individually, but get out of sync with one another pretty quickly after running the scene: Imgur: The magic of the Internet. I fixed this problem once by doing the following:

var movement = Vector2(0, 200)
var true_pos

func ready():
true_pos = position

func _process(delta):
true_pos += movement*delta
position = true_pos

This way I made sure that the platform was always moved exactly 200*delta from the position it had last frame. But after enabling Sync To Physics (which I had to do for my character to stay and the platform correctly when it moved), this method doesn’t work anymore as the platforms start jittering wildy when I use true_pos (for some reason). So what do I do here? I should probably mention that the platforms change direction when they collide with a solid block, which I suspect is somehow where they get out of sync, though I’m not sure why.

As a side note the platforms don’t collide with one another, so that’s not causing the issue either.

MOSN | 2019-05-20 13:27