# How do I calculate a rotation speed to match movement speed

0 favourites
• 5 posts
From the Asset Store
Run and Jump in 3 Dimensions! Take your platformer to the next level!
• 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?

• Is the object still moving, or is it just changing angles?

• 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'.

• 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.

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• 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!

• 5 posts