How do I rotate an object clockwize around a point?

Get help using Construct 2

Post » Wed Apr 19, 2017 4:13 pm

Might sound simple but I couldn't find a definite solution in the forum.

I have a objects that should rotate clockwise around another sprite. The distance to this sprite can vary, but the rotation speed has to be constant. For example the far one would take longer to rotate around the object the closer one would orbit faster, but they would have the same "speed". Pixels per second.

Any idea how I would go about that?
Follow my progress on Twitter
or in this thread Archer Devlog
B
42
S
18
G
19
Posts: 1,058
Reputation: 14,050

Post » Wed Apr 19, 2017 4:31 pm

I can get the speed with this formula. angle = 20 / ((2*Pi*R)/360) but the distance to the pivot can change.

So how do I rotate something clockwise around that moving point?
Follow my progress on Twitter
or in this thread Archer Devlog
B
42
S
18
G
19
Posts: 1,058
Reputation: 14,050

Post » Wed Apr 19, 2017 4:41 pm

If it's moving clockwise then set its angle to angle(self.x,self.y,other.x,other.y)
Image ImageImage
B
172
S
50
G
183
Posts: 8,440
Reputation: 115,599

Post » Wed Apr 19, 2017 5:30 pm

tunepunk wrote:Might sound simple but I couldn't find a definite solution in the forum.

I have a objects that should rotate clockwise around another sprite. The distance to this sprite can vary, but the rotation speed has to be constant. For example the far one would take longer to rotate around the object the closer one would orbit faster, but they would have the same "speed". Pixels per second.

Any idea how I would go about that?



@tunepunk

Im not 100% sure what you mean the "far one would take longer to rotate" If they have the same speed they both rotate at the same speed, but see if this can help:
you can adjust the radius and speed from the local variables

https://www.dropbox.com/s/spe0gttivvzwhpj/OrbitPlanets.capx?dl=0
B
41
S
25
G
87
Posts: 309
Reputation: 48,096

Post » Wed Apr 19, 2017 5:37 pm

I believe he wanted a constant linear speed. Here's my take on it, using your formula.

https://www.dropbox.com/s/59lavr8k6xsb2 ... .capx?dl=0
B
76
S
31
G
27
Posts: 1,015
Reputation: 20,790

Post » Wed Apr 19, 2017 5:51 pm

Magistross wrote:I believe he wanted a constant linear speed. Here's my take on it, using your formula.

https://www.dropbox.com/s/59lavr8k6xsb2 ... .capx?dl=0


Hou, I see now!, nice one man
B
41
S
25
G
87
Posts: 309
Reputation: 48,096

Post » Wed Apr 19, 2017 6:36 pm

Just so happens I'm creating game that uses that mechanic.
Check out my template:

https://www.dropbox.com/s/gqqa39cq2ds7k ... .capx?dl=0
Image Image Image
B
32
S
12
G
27
Posts: 761
Reputation: 17,246

Post » Wed Apr 19, 2017 6:44 pm

Magistross wrote:I believe he wanted a constant linear speed. Here's my take on it, using your formula.

https://www.dropbox.com/s/59lavr8k6xsb2 ... .capx?dl=0


Close but no cigar. But I think I have something to work with. Thanks.

What I'm trying to do is more of a movement system.

1 The red box should always face the Mouse pointer. This is where it is looking.
2 pressing arrow up or down should move the box closer or further from the mouse pointer.
3. Pressing left or right should orbit the red box around the mouse pointer, clockwise or anti-clockwise. Based on the distance to the mouse pointer (this distance is relative)

I think I have what I need from your example to solve the last few bits. Thanks.
Follow my progress on Twitter
or in this thread Archer Devlog
B
42
S
18
G
19
Posts: 1,058
Reputation: 14,050

Post » Wed Apr 19, 2017 6:54 pm

MPPlantOfficial wrote:Just so happens I'm creating game that uses that mechanic.
Check out my template:

https://www.dropbox.com/s/gqqa39cq2ds7k ... .capx?dl=0


Yes something like that exactly. I just need to make the distance variable based on distance to mouse pointer.
Follow my progress on Twitter
or in this thread Archer Devlog
B
42
S
18
G
19
Posts: 1,058
Reputation: 14,050

Post » Wed Apr 19, 2017 6:57 pm

tunepunk wrote:Yes something like that exactly. I just need to make the distance variable based on distance to mouse pointer.

Yup. Just modify the ROT_RADIUS instance variable to your liking.
Image Image Image
B
32
S
12
G
27
Posts: 761
Reputation: 17,246

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 9 guests