Mytts Posted September 11, 2014 Share Posted September 11, 2014 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 More sharing options...
lewster32 Posted September 11, 2014 Share Posted September 11, 2014 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 More sharing options...
Mytts Posted September 11, 2014 Author Share Posted September 11, 2014 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 More sharing options...
lewster32 Posted September 11, 2014 Share Posted September 11, 2014 I fear it's not quite that simple, but you can certainly give it a go. The physics stuff is actually not that complex and it's all well documented, but I think the slowdown may not be straightforward to fix. Link to comment Share on other sites More sharing options...
Mytts Posted September 11, 2014 Author Share Posted September 11, 2014 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 More sharing options...
JUL Posted September 11, 2014 Share Posted September 11, 2014 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 More sharing options...
lewster32 Posted September 11, 2014 Share Posted September 11, 2014 It's not crashing, it's the results of the simulation which become inaccurate and slow down when the framerate drops. Link to comment Share on other sites More sharing options...
JUL Posted September 11, 2014 Share Posted September 11, 2014 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 More sharing options...
Mytts Posted September 11, 2014 Author Share Posted September 11, 2014 Well I haven't used body.acceleration.Body.velocity is reliable as long as you know the computer can run at 60 fps... But if they drop down below 30 it becomes somewhat unrealiable... Link to comment Share on other sites More sharing options...
JUL Posted September 11, 2014 Share Posted September 11, 2014 That's what I use in the game loopupdate_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 More sharing options...
Mytts Posted September 11, 2014 Author Share Posted September 11, 2014 Wow thanks Jul, that might actually be somewhat of a solution as well. I'll definitely keep that one in mind too! ^^ Link to comment Share on other sites More sharing options...
Glaydur Posted September 12, 2014 Share Posted September 12, 2014 Awesome! I was about to ask this but was afraid I was just gonna get told to buy a better PC I do hope that the next few updates of Phaser will address this. Link to comment Share on other sites More sharing options...
Recommended Posts