Jump to content

Velocity unreliable


Mytts
 Share

Recommended Posts

So I decided to use Arcade physics for my game and it seemed like it had some really awesome features. One of the problems I encountered though was that for the arcade system to be fully functinoal, it seemed like I had to use velocity to make movements, rather than just assigning the X and Y. This wans't a problem and I quickly adjusted.

Now the problem came today, when another player was supposed to test the game. Her computer didn't handle it as well and that's when I realized that velocity is based on how much time each update takes. This is a huge problem because this meant that on a lower-end machine the player would sometimes drop through the floor! This game is supposed to be used at an event, so that's REALLY unfortunate.

Is there ANY way I can change this? So velocity always assumes a certain amount of time passed between each frame?

Link to comment
Share on other sites

You can move physics-enabled objects by setting body.moves = false, though collisions will be unreliable as a result. The separation routine which causes physics objects to hit one another and react accordingly is based on velocity, which cannot be calculated accurately if an outside force is directly applying positional values to the object.

 

As for your issue with low framerate affecting the physics simulation, this is a problem and I'm not entirely sure if there's a way to fix it...

Link to comment
Share on other sites

Yeah, I kinda guessed that there was no way to move the directly, and I can see why, I just hoped there was something I could do :/

I suppose in worst case I could edit my version of phaser, and hardcode the timestamp or something ^^

Link to comment
Share on other sites

Well, as far as I know, it uses some sort of variable to know how many miliseconds passed since last frame, if i made that variable always be 15 miliseconds, I think that should do the trick. but I'd rather find a solution that doesn't force me to make hacks to the original source code ^^

Link to comment
Share on other sites

If I may...

 

From my tests, body.velocity IS reliable, what is less, however, is body.acceleration, some crashes occured, using 2.0.7 and firefox 31/32 on macosx snow leopard running on an old mac book pro.

 

That's my piece of experience.

 

Are you using body.acceleration, somehow ?

Link to comment
Share on other sites

About body.acceleration, It's crashing with me.

That's why I don't use it, I wanted to, but got crashes at some point.

 

Now from that point two options:

 

1) Denial (I'm probably not doing it right, that must be that, so it's not worth any consideration since everyone will do it right, case closed)

 

2) Consider it, and leave rooms for the possibility that at some point, there might be a problem that went unoticed until now.

 

But that's just my opinion based on my experience, and I'm just sahring it, that's all.

Link to comment
Share on other sites

That's what I use in the game loop

update_Timeout is a variable of mine

   
    if (game.time.time> update_Timeout) {
      

      //my bigFunctions here and/or my loops and everything I don't want calculated 60 times per second (collisions excluded for obvious reason)
   

     update_Timeout= game.time.time+80;  
    }
 

 

So it gets calculated around 30 times per second or so instead of 60, which would be a bit over the top for what I need, and leaves more rooms for the rest

 

 

 

 

I hate when my computer fan starts, I just want it to remain silent, all the tilme.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...