How do I make earth rotate around the sun?

Get help using Construct 2

Post » Fri Oct 28, 2011 12:30 am

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 its Image Point.
B
230
S
6
G
9
Posts: 88
Reputation: 12,871

Post » Fri Oct 28, 2011 12:35 am

Take a look at the Pin example that comes with the latest build, that should help you.
B
72
S
25
G
9
Posts: 383
Reputation: 10,661

Post » Fri Oct 28, 2011 12:47 am

I see. In that example the object rotates, then others move around. This is the only way?

I mean, I dont want the object in the center rotates!
B
230
S
6
G
9
Posts: 88
Reputation: 12,871

Post » Fri Oct 28, 2011 12:50 am

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!Ashley2011-10-28 00:51:23
Scirra Founder
B
378
S
220
G
84
Posts: 23,868
Reputation: 188,069

Post » Fri Oct 28, 2011 2:22 am

I know @Ashley! Math is good!

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!

Jailson2011-10-28 02:32:31
B
230
S
6
G
9
Posts: 88
Reputation: 12,871

Post » Fri Oct 28, 2011 12:45 pm

Yes please Jailson, post the capx for this very example.
I added this topic in the FAQ.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
268
S
96
G
67
Posts: 7,218
Reputation: 73,727

Post » Fri Oct 28, 2011 12:58 pm

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

But if you want it here, no problem, here it is.
B
230
S
6
G
9
Posts: 88
Reputation: 12,871

Post » Fri Oct 28, 2011 1:04 pm

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.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
268
S
96
G
67
Posts: 7,218
Reputation: 73,727

Post » Fri Oct 28, 2011 3:52 pm

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.
Image ImageImage
B
164
S
49
G
138
Posts: 7,956
Reputation: 91,878

Post » Wed Jan 11, 2012 6:17 pm

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.
B
4
G
2
Posts: 11
Reputation: 774

Next

Return to How do I....?

Who is online

Users browsing this forum: Alex Bryant, kiko2015, Momio and 8 guests