0 Favourites

How do I: Make a sprite circle another sprite?

  • Hey guys!

    I am new to Construct 2, and I am building a platformer.

    My question is: How do I make a sprite fly around another sprite? (For instance: to simulate a smaller sprite "moving/flying around" a larger sprite on its x-axis, and perhaps move between layers to simulate the effect of the smaller sprite moving behind the larger sprite) ...

    This image illustrates my question:

    Thanks in advantage and best regards!

    • Jacob

    ---------------------------------------------------------------------------------------------------------------------------------------------------------------

    Edit: Due to incapability in using the english language I changed the word "orbit" with "circle" in order to explain myself better.

  • Look here:

  • Look here:

    Hey, Lamar

    Thanks for replying

    I went to https://www.scirra.com/forum/viewtopic.php?f=159&t=185994&p=1093136&hilit=orbit#p1093136 and had a look, where I stumbled upon R0J0hound's solution.

    "Universal gravitation" is the formula you'd want to look at to do the gravity force between two objects.

    Force = G*mass1*mass2/distance^2

    That's the magnitude of the force, the direction is toward each other.

    Now an object will orbit another if it's velocity is perpendicular to the direction of the other object and it's speed is sqrt(massOther/distance).

    Here's my test of it:

    Now I haven't played solar but considering a good orbit just doesn't happen then I suspect that some additional force is used to steer the smaller objects to get in a good orbit.

    After having a look at R0J0hound's capx file I tried making a new project myself to test the code, but I don't know how to make the same code with two different sprites (a smaller sprite and a larger sprite of different colors), as I am still new to Construct 2. Nor do I know how to make the smaller sprite circle the larger one as presented on the picture in the original post. In other words: It's quite complicated for me to understand R0J0hound's solution.

    Any pointers or suggestions? Thanks in advantage

  • > Look here:

    >

    >

    >

    Hey, Lamar

    Thanks for replying

    I went to https://www.scirra.com/forum/viewtopic.php?f=159&t=185994&p=1093136&hilit=orbit#p1093136 and had a look, where I stumbled upon R0J0hound's solution.

    > "Universal gravitation" is the formula you'd want to look at to do the gravity force between two objects.

    > Force = G*mass1*mass2/distance^2

    > That's the magnitude of the force, the direction is toward each other.

    >

    > Now an object will orbit another if it's velocity is perpendicular to the direction of the other object and it's speed is sqrt(massOther/distance).

    >

    > Here's my test of it:

    >

    > Now I haven't played solar but considering a good orbit just doesn't happen then I suspect that some additional force is used to steer the smaller objects to get in a good orbit.

    >

    After having a look at R0J0hound's capx file I tried making a new project myself to test the code, but I don't know how to make the same code with two different sprites (a smaller sprite and a larger sprite of different colors), as I am still new to Construct 2. Nor do I know how to make the smaller sprite circle the larger one as presented on the picture in the original post. In other words: It's quite complicated for me to understand R0J0hound's solution.

    Any pointers or suggestions? Thanks in advantage

    Not my CAPX so let's jingle R0J0hound and see if he can help.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • dropbox.com/s/ir5v6fzg54hvg8p/orbit.capx

    Thank you SO MUCH, newt! That is exactly what I was looking for

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)