How to make an orbital mechanic

how can i make a mechanic that acts as follows?:

think of the object gravity mechanic as the basis. i want an object (player) to float about the planet. it moves constantly in a clockwise circle. when the screen press is held, the player gets closer and closer to the planet. on release, the player slowly goes back up to the original position. can i do this?

i made a post similar to this, but i was not clear before. i wanted to reiterate, as some things i want have changes.

You can use as reference the gravity example and modify at your need.

I might make a video on this someday but I’d use the ‘rotate object around’ action to get your object to orbit around a point. Then you just need to animate/lerp the distance the object orbits to achieve the effect

1 Like

Thank you. What do you mean by lerping the distance? Also, side note, can I make the objects different distances from the center of the circle?

Lerp means you move smoothly from one value to another. It’s one of the expressions you can use in setting a value. I demonstrate how to use it in this video: How to make an uncentered camera | GDevelop 5 tutorial - YouTube (though the main focus of the video is moving the camera the main features are similar)

I also used the rotate around in this tutorial: Bow Tutorial Walkthrough | GDevelop 5 - YouTube

it’s a slightly longer walkthrough but there is a section where I talk through rotating a sprite’s arms around the shoulders based on where the mouse is. That uses the rotate around action and a custom point I added to my sprite.

Hope those are helpful!


thank you! i’ll check them out