How do I calculate a rotation speed to match movement speed

Get help using Construct 2

» Thu Sep 15, 2016 3:04 pm

I have an object moving 20 pixels per tick. When the object reaches a certain point a sprite is created which will be a "pivot point" to which the moving object will pin itself to. At this point the movement stops and the object starts to rotate instead around this pivot point, until it reaches a certain angle.

Is there any formula to calculate so that the rotation around that pivot will have the object move at the same rate of 20 pixels per tick? For this example let's say the pivot point is 100 pixels to the left of the moving object.

How many degrees per tick would be equal to the object moving at 20 pixels per second around this pivot point?
or in this thread Archer Devlog
B
42
S
18
G
19
Posts: 1,060
Reputation: 14,054

» Thu Sep 15, 2016 3:41 pm

Is the object still moving, or is it just changing angles?
B
172
S
50
G
183
Posts: 8,443
Reputation: 115,605

» Thu Sep 15, 2016 4:03 pm

Distance for a full circle = 2*Pi*R

Distance for a certain angle = ((2*Pi*R)/360)*angle .. R being distance(object.x,object.y,pivot.x,pivot.y) ... on the moment of collision.

Speed = distance / time

It must travel at 20 pixels / tick

So for 1 tick .. ((2*Pi*R)/360)*angle should be = 20

((2*Pi*R)/360)*angle = 20 ... how much angle to rotate per tick ? (R is known)

((2*Pi*R)/360) / 20 = 1/angle ... or angle = 20 / ((2*Pi*R)/360)

Hope this stands, not that big of a math brain. Dont forget to 'dt'.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

» Thu Sep 15, 2016 4:48 pm

When it's pivoting, you can use this:

Angle(Obj.X, Obj.Y, Pivot.X, Pivot.Y) ± 90

To set the angle, and continue moving 20px forward each tick. In this case the ± will be decided by whether the pivot is to the left or to the right of the object according to how it's facing.
The LEVEL GENERATOR TOOLKIT

24 functions dedicated to producing randomly generated terrain for all kinds of games.
B
25
S
7
Posts: 247
Reputation: 2,318

» Thu Sep 15, 2016 9:02 pm

99Instances2Go wrote:Distance for a full circle = 2*Pi*R

Distance for a certain angle = ((2*Pi*R)/360)*angle .. R being distance(object.x,object.y,pivot.x,pivot.y) ... on the moment of collision.

Speed = distance / time

It must travel at 20 pixels / tick

So for 1 tick .. ((2*Pi*R)/360)*angle should be = 20

((2*Pi*R)/360)*angle = 20 ... how much angle to rotate per tick ? (R is known)

((2*Pi*R)/360) / 20 = 1/angle ... or angle = 20 / ((2*Pi*R)/360)

Hope this stands, not that big of a math brain. Dont forget to 'dt'.

Thanks, that worked perfectly. angle = 20 / ((2*Pi*R)/360)

Just the kind of formula I was looking for. Thanks!
or in this thread Archer Devlog
B
42
S
18
G
19
Posts: 1,060
Reputation: 14,054