How would I code a KinematicBody2D to move_and_slide() to a specific position in a specific time?

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

I am a beginner coder and I was able to code everything I wanted until I had to code a function that moves a body to a position in expected time. For example I want my body to go Vector2(100, -100) from Vector2(0, 0) in 10 seconds. This one really stumped me. I’m not asking for an entire code that I could copy and paste, I only want an idea of how I could accomplish it. I know so little about physics and such.

:bust_in_silhouette: Reply From: exuin

Use division. (Vector2(0, 0) - Vector2(100, -100)) / 10 seconds is Vector2(-10, 10) per second. That is your velocity vector. Put it into move and slide.