Moving platform using MoveAndSlide()?

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

I’ve read the tutorials where you can make moving platforms using an AnimationPlayer. However, I’m curious as to why MoveAndSlide() for movement isn’t a better option?

Here’s the hierarchy for the node I’m testing:

KinematicBody2D
    Sprite
    StaticBody2D
        CollisionShape2D

When my player stands on the platform, they move along with it, but they aren’t perfectly perched on top of it. (Yes, I’m using MoveAndSlideWithSnap() for the player). Would it be possible to pass the platform’s velocity to the player to lock them to the top of the platform? Or should I just stick with the AnimationPlayer?

:bust_in_silhouette: Reply From: Addmix

You could use the get_floor_velocity() function to easily get the velocity of the platform. KinematicBody2D — Godot Engine (3.5) documentation in English