# How do I rotate an object clockwize around a point?

Get help using Construct 2

### » 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?
or in this thread Archer Devlog
B
46
S
21
G
19
Posts: 1,123
Reputation: 14,613

### » 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?
or in this thread Archer Devlog
B
46
S
21
G
19
Posts: 1,123
Reputation: 14,613

### » 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)
B
176
S
50
G
200
Posts: 8,632
Reputation: 124,565

### » 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:

https://www.dropbox.com/s/spe0gttivvzwhpj/OrbitPlanets.capx?dl=0
B
51
S
31
G
95
Posts: 425
Reputation: 53,241

### » 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
80
S
33
G
27
Posts: 1,027
Reputation: 21,114

### » 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
51
S
31
G
95
Posts: 425
Reputation: 53,241

### » 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
"The intent is to provide subscribers with a sense of pride and accomplishment for unlocking different features...."
B
40
S
17
G
32
Posts: 818
Reputation: 20,629

### » 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.
or in this thread Archer Devlog
B
46
S
21
G
19
Posts: 1,123
Reputation: 14,613

### » 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.
or in this thread Archer Devlog
B
46
S
21
G
19
Posts: 1,123
Reputation: 14,613

### » 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.

"The intent is to provide subscribers with a sense of pride and accomplishment for unlocking different features...."
B
40
S
17
G
32
Posts: 818
Reputation: 20,629

Next

### Who is online

Users browsing this forum: No registered users and 30 guests