0 Favourites

physics velocity

  • Okay, I have a long and complicated problem that I have been dealing with and I have finally gotten to the bottom of it - but alas I can't figure it out.

    When I run the debugger I notice that an objects velocity not is pixels per second which is what the manual says. It is also not pixels per tick. In the end I have no clue what it is.

    I am basing this off of the following code:

    (delta X)*cos(90)

    + (delta Y)*sin(90)

    which should theoretically return the distance an object has traveled along an arbitrary angle (polar projection). In this case it should be the same as the y velocity of the object but it is not. Also if I just check deltaX and DeltaY and compare them against velocity X,Y they are off. Deltax is 0.833(and then some, give or take) * velocity x. What is going on? Did I miss something...?

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • The physics has two modes "fixed" (default) and "Framerate Independent".

    With "Fixed" 1/60 is used instead of dt. This is the default and useful to have similar results from run to run. The side effect is if your fps dips below 60 then the physics objects will move slower.

    For example normally if the velocity is set to 100 and the fps is 60 then 1/60 and dt will be about the same and the speed will be 100pixels/second.

    On the other hand say the fps is 30 then dt will be about 1/30 or twice as much as 1/60 so the speed will be 50pixels/second.

    With your result of 0.833x I'd guess your fps is about 50.

    You can set the stepping mode to "Framerate Independent" with an action to make the physics use dt instead of 1/60. With a stable fps of 60 you'll not notice much of a different between the modes. The simulation can become unstable if the fps varies too much but the speeds will remain the same at 100pixels/second. At least until the fps drops below 30fps. After that 1/30 is used instead of dt. It would seem that is the minimum timestep that will be used. The result is slowdowns again much like "fixed".

    Anyway that's my breakdown of what's happening and here's my test capx:


    On another note, AnD4D Colludium I think this info is relevant to the topic you made here:http://www.scirra.com/forum/physics-forces_topic85125.html

    In summery setting the stepping mode to "Framerate Independent" will help with your situation and keep the speeds matching since your fps is in the range of 30-60. If your fps drops below 30fps then all the physics objects will slow down.

  • Sorry, to clarify, I am in frame rate independent mode. I talked to Ashley about it and it may be an issue with the debugger not reporting the right value. (I am still waiting on the status of that) So, basically, just because the two values don't look the same in the debugger doesn't mean that they aren't.

    You can see an example here: dropbox.com/s/h3eku40e03wtill/debugProblem.capx

    You have to run in debug mode and then look at the global variable and compare it to the velocity variable (if that makes sense)....

    Thanks for all the help!

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