Hersir Posted June 2, 2017 Share Posted June 2, 2017 Hi, I have rotating platform and target on it that rotates together with it. Also there is player that has jump animation, so I want to calculate when I need to jump to land on target. I created naive implementation in this PG. It works fine if FPS is above animation FPS (25), but I as soon FPS drops player starts to miss target. (Added function to generate knots and added performance CPU throttle on chrome 20x); Probably because interpolation that I need to include un calculation. Is it even possible to predict where will be target after jump animation is completed? Any suggestions are welcome Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 2, 2017 Share Posted June 2, 2017 I guess you just need to adapt to animation ratio with scene.getAnimationRatio (http://doc.babylonjs.com/classes/2.5/scene#getanimationratio-rarr-number) It will give you the scale to apply to animation to align to expected framerate. For instance if you run at 15fps and animation expect to run at 30fps then the ratio will be 2 Quote Link to comment Share on other sites More sharing options...
JohnK Posted June 3, 2017 Share Posted June 3, 2017 Not sure whether this was the problem or not but if last frame is 360 that makes 361 frames, and last frame 20 makes 21 frames, so decreased last frame by 1. This PG I changed to set animation frame rate at start so you can make it larger than render frame rate and it still seems to work. Changed so variable for no other reason than I had started to set them as globals at top and then realised you had them in the WillLandOnTarget function so no good reason really. http://www.babylonjs-playground.com/#GCSXQ5#9 Hope this helps, by the way have tried 525 as animation frame rate and it just lands on edge of target. Quote Link to comment Share on other sites More sharing options...
Hersir Posted June 5, 2017 Author Share Posted June 5, 2017 @JohnK Thanks for input. But if I comment in function to generate 1000 knots and add CPU throttling (20x slowdown) on chrome it lands in opposite corner I am doing something wrong, as looks like that offset is related to difference between animation FPS and real FPS, the bigger the difference more off it gets. Quote Link to comment Share on other sites More sharing options...
Hersir Posted June 5, 2017 Author Share Posted June 5, 2017 Oh boy I am stupid... Added shadow objects to see if calculations are correct PG, and looks like they are correct, but because of low frame rate, platform will jump over lot of frames and never will be at calculated position. Thats the reason why with lower frame rate gap is getting bigger and bigger. Will need to think how to overcome this problem, Quote Link to comment Share on other sites More sharing options...
Hersir Posted June 5, 2017 Author Share Posted June 5, 2017 One version would be to remove current animation, create new from current position till angle needed for jump and then add back full circle after animation is finished Quote Link to comment Share on other sites More sharing options...
Hersir Posted June 5, 2017 Author Share Posted June 5, 2017 Splited animation worked PG Quote Link to comment Share on other sites More sharing options...
JohnK Posted June 5, 2017 Share Posted June 5, 2017 Glad you got it to work. 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.