monkeyface Posted October 25, 2015 Share Posted October 25, 2015 I am having trouble with my camera not moving when I press the movement keys... after some debugging I found it's because getDeltaTime returns 0. If I hardcode this to return 0.01 the camera works fine... but what would make it return 0? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 26, 2015 Share Posted October 26, 2015 How is your render loop? deltaTime is updated by engine.beginFrame which is automatically called when you use engine.runRenderLoop(function(){}) Quote Link to comment Share on other sites More sharing options...
fenomas Posted October 26, 2015 Share Posted October 26, 2015 Yeah, I had this issue until I changed my render loop to:this._engine.beginFrame()this._scene.render()this._engine.endFrame() Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted October 26, 2015 Share Posted October 26, 2015 Hmm, would you mind refreshing my memory, beginFrame and endFrame are in the engine just to help calculating FPS, right ? Quote Link to comment Share on other sites More sharing options...
monkeyface Posted October 26, 2015 Author Share Posted October 26, 2015 Calling beginFrame() or endFrame() for me doesn't help... I had to override the function completely. I'm not doing anything special. The only thing perhaps is that I'm using Typescript... maybe that's changing the order or accessibility of something? I don't really know enough about the engine internals to know where to look though.It seems to happen with both the stable and beta versions of babylon.document.addEventListener("DOMContentLoaded", function () { if (BABYLON.Engine.isSupported()) { canvas = <HTMLCanvasElement>document.getElementById("renderCanvas"); engine = new BABYLON.Engine(canvas, true); divFps = <HTMLElement>document.getElementById("fps"); scene = createScene(); // Resize window.addEventListener("resize", function () { engine.resize(); }); camera.attachControl(canvas, false); engine.runRenderLoop(function () { if (divFps) { divFps.innerHTML = engine.getFps().toFixed() + " fps"; } scene.render(); // Animations skybox.rotation.y += 0.0001 * scene.getAnimationRatio(); }); }}, false); Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 26, 2015 Share Posted October 26, 2015 can you share your code somewhere where I can run it? I tried your code and it's working great for me Quote Link to comment Share on other sites More sharing options...
monkeyface Posted November 6, 2015 Author Share Posted November 6, 2015 I figured this out in the end... it was because the engine constructor was being called twice in different parts of the app. GameMonetize 1 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.