Speed of a Sine

0 favourites
  • 4 posts
From the Asset Store
Have you ever dreamed of playing in a Speedball game or tournament?
  • I have a sprite with a sine behavior; Period: 5, Magnitude: 100. How do I measure its speed?

  • The linear speed is variable, I guess you can calculate it by checking the position at several time intervals.

    You initialize the oldXposition of the sprite.

    Every S seconds you get the newXposition of the sprite, calculate the speed with ABS(newXposition-oldXposition) and just afterwards update the oldXposition with the newXposition value.

    This will give you the speed in px per S seconds you have defined. If the S value is too small, reaching the per tick system limit, I guess that it will give bad readings. The speed of the sine goes from 0 in the edges to the max speed when passing the initial point.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Will this method give me an accurate number? It seems that sine behavior does not have one constant speed as it is always changing.

    There has to be a way. Maybe there is a way to measure how many pixels it is moving every tick?

  • Change the every x seconds in the above answer to every tick and....

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