How do I calculate a rotation speed to match movement speed

Get help using Construct 2

Post » 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?
Follow my progress on Twitter
or in this thread Archer Devlog
B
35
S
15
G
17
Posts: 944
Reputation: 12,210

Post » Thu Sep 15, 2016 3:41 pm

Is the object still moving, or is it just changing angles?
Image ImageImage
B
168
S
50
G
163
Posts: 8,225
Reputation: 105,069

Post » 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
27
Posts: 2,451
Reputation: 20,366

Post » 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: 237
Reputation: 2,296

Post » 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!
Follow my progress on Twitter
or in this thread Archer Devlog
B
35
S
15
G
17
Posts: 944
Reputation: 12,210


Return to How do I....?

Who is online

Users browsing this forum: el3um4s, Ryan Kocourek, TylerJS and 9 guests