securet Posted December 13, 2016 Share Posted December 13, 2016 what would be the best approach to move a Mesh constantly independently form framedrops? mesh.moveWithCollisions(new BABYLON.Vector3(x,y,z)) or would moveWithCollisions(new BABYLON.Vector3(x*scene.getAnimationRatio(),y*scene.getAnimationRatio(),z*scene.getAnimationRatio()) be better or would an other approach be better? Quote Link to comment Share on other sites More sharing options...
RaananW Posted December 13, 2016 Share Posted December 13, 2016 well, it all depends how you define your velocity (the variable provided to moveWithCollisions). You could multiply it by deltaTime, divide it by the current FPS, or use the animation ratio (which is set like this: animationRatio = deltaTime * (60.0 / 1000.0);) . All depends on your initial velocity vector. Quote Link to comment Share on other sites More sharing options...
securet Posted December 13, 2016 Author Share Posted December 13, 2016 moveWithCollision(velocity*movex*animationRatio,....) should result in a smooth movement? Quote Link to comment Share on other sites More sharing options...
RaananW Posted December 13, 2016 Share Posted December 13, 2016 again, depends on your variables and your scale moveWithCollision(new Vector3(0.0001, 0.0001, 0.0001)) will be smooth for sure, but will probably get you nowehere. If all of your meshes are 100000 units big, then setting the velocity to 10 will probably be smooth as well. Just experiment. Give it a try, you will figure it out. Quote Link to comment Share on other sites More sharing options...
securet Posted December 13, 2016 Author Share Posted December 13, 2016 k, ty. Maybe I used the wrong word, by smooth I meant the speed of the mesh should stay the same, independent from the FPS So I want the mesh to travel the same amount of space no matter if the FPS is at 60 or 20. So multiplying by the animationRatio should do the job. Quote Link to comment Share on other sites More sharing options...
RaananW Posted December 13, 2016 Share Posted December 13, 2016 Yep, that's the right factor to use 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.