Tomek Posted October 31, 2018 Share Posted October 31, 2018 Hello, I want to control the camera position with 'WASD' keys. More specifically the targetScreenOffset. I managed to do it but now I want to add animation so the movement is smooth. However, when you hold the key down animations overlap each other causing some stutter. Also when I click rapidly different keys there are some "jumps" from one position to another. Here's the example: https://playground.babylonjs.com/#92LK47#7. How could I fix it, maybe with some throttling? Quote Link to comment Share on other sites More sharing options...
Guest Posted October 31, 2018 Share Posted October 31, 2018 You should add a bit of inertia and not use animations. Instead just accumulate your movement into a vector, use this vector to move the offset and then (on every frame) multiply this vector by an inertia value Here is an example in Bjs code: https://github.com/BabylonJS/Babylon.js/blob/master/src/Cameras/babylon.targetCamera.ts#L311 Quote Link to comment Share on other sites More sharing options...
Tomek Posted November 1, 2018 Author Share Posted November 1, 2018 @Deltakosh Thanks for the tips! I solved it - https://playground.babylonjs.com/#92LK47#12. 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.