How do I make earth rotate around the sun?

0 favourites
  • 15 posts
From the Asset Store
10 Royalty free tracks, 10 stings and 34 sound FX to use in your indie games & projects.
  • I know, should not have missed some math classes. I am trying to make an object move around another, like earth move around the sun. But I don't know how to do it.

    I need the object that is moving always face the object it is moving around.

    Sorry for my poor english.

    It would be nice if it were possible to rotate an object using it?s Image Point.

  • Take a look at the Pin example that comes with the latest build, that should help you. <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I see. In that example the object rotates, then others move around. This is the only way?

    I mean, I don�t want the object in the center rotates!

  • The math you need is:

    Set X to CenterX + cos(angle) * dist

    Set Y to CenterY + sin(angle) * dist

    CenterX/Y defines the center point of the circle, at the give angle, with a radius of 'dist'.

    Math is actually really helpful in game creation, it's worth brushing up!

  • I know Ashley! Math is good! <img src="smileys/smiley9.gif" border="0" align="middle">

    Thanks to your formula I was able to reach my goal. I would like to share what I just learned.

    Here is an example of what I wanted to do. The project file (.capx) is also available!

  • Yes please Jailson, post the capx for this very example.

    I added this topic in the FAQ.

  • Kyatric, the .capx is available at the example link. Below the demo.

    But if you want it here, no problem, here it is.

  • Oh sorry, I didn't pay attention and missed the link.

    Well at least it's here too now.

    Good job, thanks for the example.

  • Yeah that's a pretty standard formula, and can be applied in a ton of different ways.

    ..... wouldn't mind seeing it as an expression in C2.

  • This is something I'd been trying to get to work, so this is very helpful. What would you need to do to let the player control rotation? I'm thinking of using this method for a targeting cursor that rotates around the main character when the player aims.

  • just the angle between the mouse and the character

    angle(character.X,character.Y,mouse.x,mouse.y)

    you plug that in the formula above and that should do the trick

  • This is something I'd been trying to get to work, so this is very helpful. What would you need to do to let the player control rotation? I'm thinking of using this method for a targeting cursor that rotates around the main character when the player aims.

    Something like:

    sprite set position to player.x +cos(angle(player.x,player.y,mouse.x,mouse.y))*dist

    player.y +sin(angle(player.x,playr.y,mouse.x,mouse.y))*dist

  • wow that was nice thanks

  • It's working, I tried to make another object rotate around the previous one and it worked

  • But how I can change the center point in realtime without the object be wrapped at the top of second center point ?

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