###

» Mon Oct 03, 2016 7:20 pm

First things first : Units.

In c2, speed is usually expressed in pixels/tick or pixels/seconds. Two different units.

The speed (expression) of bullet behavior (look in expressions panel) is expressed as pixels/second. There is a very important thing that comes with that knowledge. Wherever you see 'pixels/second' it means that this speed is already frame-independent.

So what ever solution, it must be frame-independent too. Else, you could have it right on your computer, but on another device it will be totally wrong.

If you gonna rotate it like ...

Every tick > rotate 1 degree clockwise

You will have to frame correct it like

Every tick > rotate 60 * dt degrees clockwise

Now, if we take a look at the Rotate behavior, its speed (expression) is also expressed as pixels/second. Meaning, the Rotate behavior is also already frame-independent. Well, why make it difficult, lets use it.

Ok so .. Speed is distance/time.

The distance a circle makes in 1 rotation = 2*R*pi.

R in this is the radius. 2*R is the width of the wheel.

So it is 'width of the wheel' * pi.

The same speed would be when car.bullet.speed (pixels/second) = Wheel.width * pi (pixels/second)

But, we need this in degrees/second

1 degree = a distance = Wheel.width * pi / 360 (pixels)

so

1 / (Wheel.width * pi / 360) degrees = 1 pixel

or

360 / (Wheel.width * pi) degrees = 1 pixel

For any pixel

x * (360 / (Wheel.width * pi)) degrees = x * 1 pixel

Say x be the car.bullet.speed

car.bullet.speed * (360 / (Wheel.width * pi)) degrees = car.bullet.speed * 1 pixel

So .. to have the same speed, you give the rotation behavior this speed :

(car.bullet.speed * 360) / (Wheel.width * pi)

I am not that big of a math brain, hope its right, so from the head.