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

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

Modeled and textured in Blender.

#3dart #lowpoly #npbr #fantasy #hut

Shadow The Hedgehog X pixel art

I-Buki

Mio-Da!

Ibuki Mioda!

Why walk when you can jump?

Spaaaace~

These are background sprites I've created for a game I'm working on at school ^w^ Click on the post to see how the sprites connect. You won't regret it! (personally, I think it's pretty heheh)

Drawn in Piskel using my mouse. Whaddya think?

Regular exercise is key for healthy wings.

Try it out!

https://gamejolt.com/games/AeonNightmares/605184

"Day to Day" (also check spud out here he's a great guy and writer: https://soundcloud.com/spudward)

Cash Banooca

Who's is this little cutey👸 here? Thanks🙏 for a gorgeous fanart @WheNa! Feel free to share your arts, screenshots, or videos with #playzelter or #zelter hashtags! #pixelart #animating #unity3d #animated #indiegames #unrealengine #animate #conceptart