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
228
S
6
G
8
Posts: 86
Reputation: 12,295

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: 382
Reputation: 10,649

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
228
S
6
G
8
Posts: 86
Reputation: 12,295

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
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

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
228
S
6
G
8
Posts: 86
Reputation: 12,295

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
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

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
228
S
6
G
8
Posts: 86
Reputation: 12,295

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
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

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 Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

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: 99Instances2Go, Colorfish, zenox98 and 25 guests