Hi everyone. I have a task to make a moving car, The car doesn’t move itself, its wheels rotate and the road moves. And so how can i synchronize the rotation and the moving? Any ideas? Class Action is avoid to use.

The wheels (w1 and w2) moving code in Update():

`auto rot = w1->getRotation(); rot += 10 * delta * coefSpeed; w1->setRotation(rot); w2->setRotation(rot);`

The road moving code in Update():

`if ((road->getPositionX() - coefSpeed * 0.5) <= origin.x) road->setPosition(Vec2(visibleSize.width / 2 + origin.x, visibleSize.height / 4 + origin.y)); else road->setPositionX(road->getPositionX() - coefSpeed * 0.5);`

Since it’s the road that moves, let’s say the road goes from 0 to MAX speed, and let’s also take that as being 0 to 100%. Can you use that percentage to multiply by the max rotation speed in order to simulate the rotation speeding up and slowing down too? Does that make sense?

I use the coefSpeed for it, yes. If it grows up, the road moves slowlier and the wheels rotate slowlier, too. I’ve changed the way to count rotation, and now it looks like this:

`rot += coefSpeed / (2 * 3.14 * 33) * delta * 360;`

33 px is the radius of the wheel, multiplication by 360 is needed to convert to degrees.

Maybe there are another ways to synchronize, I don’t know