Athelios Posted June 29, 2016 Share Posted June 29, 2016 Hello, Don't know if it is a bug but players with different FPS move by different speed. I use FreeCamera.I have got 60 FPS and I move about three times slower then other player with 20 FPS. That's weird because players with lower FPS should move slowly. I guess there is some speed compensating code. Also if player is for some time in another browser window and switch to game immediately holding move button he move for a while by huge speed. Sorry for my English. Thanks! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 29, 2016 Share Posted June 29, 2016 Hey! How do you move your player? Is it using animation? Or using manual coding? Quote Link to comment Share on other sites More sharing options...
Athelios Posted June 29, 2016 Author Share Posted June 29, 2016 It is using same move as this: http://www.babylonjs-playground.com/#1N4XAN In this example on PC with low FPS you move much faster. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 29, 2016 Share Posted June 29, 2016 This should not be the case as camera speed is based on framerate: https://github.com/BabylonJS/Babylon.js/blob/master/src/Cameras/Inputs/babylon.freecamera.input.keyboard.ts#L85 Quote Link to comment Share on other sites More sharing options...
Athelios Posted June 29, 2016 Author Share Posted June 29, 2016 public _computeLocalCameraSpeed(): number { var engine = this.getEngine(); return this.speed * ((engine.getDeltaTime() / (engine.getFps() * 10.0))); } In my opinion this function isn't correct. Example: FPS = 40, DeltaTime = 25 Result is 0.0625 FPS = 20, DeltaTime = 50 Result is 0.25 This makes player with 20 FPS 4 times faster, but he should be 2 times faster. Shouldn't be Math.sqrt((engine.getDeltaTime() / (engine.getFps() * 10.0))) ? Quote Link to comment Share on other sites More sharing options...
Athelios Posted June 29, 2016 Author Share Posted June 29, 2016 I just tested it and with Math.sqrt is works exactly as it should. Players now move same speed regardless different FPS. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 30, 2016 Share Posted June 30, 2016 I'll apply the fix! Thanks:) Quote Link to comment Share on other sites More sharing options...
Athelios Posted June 30, 2016 Author Share Posted June 30, 2016 Thanks! You should probably change 10 coefficient too because Math.sqrt will speed up player. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.