12 years ago

GMK: Studio Code Snippet - Orbit


Code Snippet: Orbiting
Engine: Game Maker: Studio
https://www.yoyogames.com/studio

In your rotating object’s CREATE event, drag over an, “Execute Code” block and type:

// Setup the orbiting object’s variables
pDir = 0; // Where the orbiting object starts (0-360)
pDistance = 100; // The distance from the main object this orbits
pSpeed = 1; // Speed of the orbit

In your rotating object’s STEP event, drag over an, “Execute Code” block and type:

// Set the movement of your orbiting object
x = [yourObject].x + lengthdir_x(pDistance, pDir)
y = [yourObject].y + lengthdir_y(pDistance, pDir)

// Based on which direction you want, you can use +/- when adding the speed
pDir += pSpeed;

I hope that this helped anyone looking for some orbiting planets, buffs, or tornadoes in the future!

Cheers,
Joshua Long



0 comments

Loading...

Next up

Just as Pecaminosa's musicians #improvise this rendition of #LittleSunflower 🌻, so do we improvise with this post you're reading. 😂

What's coming out of your own improvs? 🤔

#Pecaminosa | #IndieDev | #OST | #Jazz

Chiaki Nanami!

🍒Did you like the game? A demo is available for free on Steam.

✌️ Thanks for playing IndieGameiacs!

⚙️ Free Demo: http://bit.ly/UniDuni

📺 Full Video: https://youtu.be/5qEbVXg7GaQ

#steam #uniduni #clops #screenshotsaturday

We made a lot of improvements on the Freezing Plains visual. Things like pine trees, tiny bushes, some rocks, and others game props!

#IndieGame | #IndieDev | #GameDev | #PixelArt | #WaifuQuest | #WifeQuest | #screenshotsaturday

Enemies can also suddenly spawn through Realm Rifts. These Rift Spawns are going to be stronger than the ones wandering around. TBD on the enemies... #screenshotsaturday #godstear #madewithunity

Finished a project I've been working on over the last few days!

Modeled and textured in Blender.

#3dart #lowpoly #npbr #fantasy #hut

I-Buki

Mio-Da!

Ibuki Mioda!

So here's the first of the zodiac signs i will make for the next weeks.

Strange Umbrella