phaselock Posted November 23, 2017 Share Posted November 23, 2017 Hi, I've gone through the stuff on skeleton animations on the babylon docs, virtually all examples involve some form of scene.registerBeforeRender or scene.registerAfterRender stuff. I would like to make an humanoid character, say, pathfind and start walking from A and then stopping automatically at B. So, the usual way to do it in C# or other languages is to have the character be at rest pose at A, blend into walk pose and then blend into rest pose at B with the waypoints given. I found that babylon scene.registerBefore/AfterRender calls will not run when the browser tab is not active. So I could have my AI start walking, tab out and then to tab back after a few minutes to find that it hadn't left Point A yet. I'm new to animating characters on the web and tried to solve it in the PG (with the dude) but can't seem to animate his position without pausing when browser tab is not active. How should I go about solving this issue ? Quote Link to comment Share on other sites More sharing options...
Raggar Posted November 23, 2017 Share Posted November 23, 2017 You could use some sort of delta. Either based on time or frames. Here's a quick example of using time, which should also be frame-independent: http://playground.babylonjs.com/#C3KABR phaselock 1 Quote Link to comment Share on other sites More sharing options...
phaselock Posted November 23, 2017 Author Share Posted November 23, 2017 Cool, thanks @Raggar ! Did a quick test on the dude, https://www.babylonjs-playground.com/#11BH6Z#319 This could work. Now to test if 3 getTime function calls per frame per AI worker consume resources when scaled. Cheers ! Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted November 23, 2017 Share Posted November 23, 2017 @phaselock You only need to do it once per frame, the value should be the same. Also, delta calculations should be reversed, timeNow - timeLastFrame = delta phaselock and Raggar 2 Quote Link to comment Share on other sites More sharing options...
Raggar Posted November 24, 2017 Share Posted November 24, 2017 Well. The timeStamp only needs to be set once, and then updated with the currentTimeStamp. timeStamp = currentTimeStamp; No idea why I didn't do that in the PG. This way, you only need to call getTime once per function call. Better yet, once per frame. If you calculate the delta once, you can use it for all your AI's. @aWeirdo phaselock 1 Quote Link to comment Share on other sites More sharing options...
Raggar Posted November 24, 2017 Share Posted November 24, 2017 http://playground.babylonjs.com/#C3KABR#2 Hmm. Any idea why the following doesn't work? http://playground.babylonjs.com/#C3KABR#3 phaselock 1 Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted November 24, 2017 Share Posted November 24, 2017 @Raggar You're only passing the value of x, not the property http://playground.babylonjs.com/#C3KABR#4 Raggar and phaselock 2 Quote Link to comment Share on other sites More sharing options...
phaselock Posted November 24, 2017 Author Share Posted November 24, 2017 @aWeirdo @Raggar , thanks guys for all the input ! Learnt smthg new today about delta time. Doesn't entirely solve my core issue but does solve THIS thread's. I'm gonna go ahead and mark it solved. Cheers ! Quote Link to comment Share on other sites More sharing options...
Raggar Posted November 24, 2017 Share Posted November 24, 2017 9 hours ago, aWeirdo said: @Raggar You're only passing the value of x, not the property http://playground.babylonjs.com/#C3KABR#4 Well, of course. Don't stay up for too long, Mr. Raggar! I just thought using the actual property would be very useful. Then you could call the function to change position, rotation etc. without having additional check in place in the function itself. 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.