Rotate according to distance

0 favourites
  • 7 posts
From the Asset Store
Simple resize and rotate events for any sprite, quick and easy event sheet that you can use for your own projects.
  • Hi to all !

    Does someone knows how to do that ?

    I'm looking for a formula that applies to a circle sprite. When the sprite moves horizontally, its rotates according to its size.

    That could be useful for wheels of a car as the object is dragged through the screen.

    Such a formula could be turned into a behavior, what do you think ?

  • Let's do some maths then !

    Length = Pi*Sprite.width*rotation(in �)/360

    So if you have the distance (dt*speed), then you have the rotation :

    Rotation = dt*speed*360/(Pi*Sprite.width)

  • Guizmus

    Oh great !

    Well I undersrand the math but practically, how will it look like in Construct ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi

    Thanks a lot !

    That's exactly what I needed ! But can you explain the formula "set angle to cartire.x degrees" ? Does it take in consideration the size of the sprite ?

  • set Angle is quite simple to understand.

    When you have a sprite selected, you see handles to resize it, and also a center point, with a handle on its side, to rotate the sprite. Basic orientation is 0�.

    If you set another angle on the sprite, it will rotate around its center, the origin point, witch you can change in the animation editing interface (dbl click on the sprite). Be carefull, there is a different center for each frame of each animations !

    How to implement the mats in C2 ? Depends how your "car" is built. If it's, let's say, 1 sprite for the body of the car, and 1 sprite per wheel, you should put those in a container.

    In the event sheet, I would create a function "car.move" (with a direction and a speed maybe ? Everything depends on your implementation). In this function, I would put some action on the car wheel sprite, "set angle to dt*car.speed*360/(3.1415*Sprite.width) + wheel.angle". Of course, you would have to change car.speed, Sprite.width and wheel.angle with the right variables, depending on the name of your objects and the behavior you use to move the car (how the speed is store)

  • Thanks for the lesson. I appreciate

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)