Panuchka Posted April 23, 2017 Share Posted April 23, 2017 Just a quick question; how to not freeze the render loop when doing "heavy" operations? Example: In my game, I have a stage that is composed of squares. The player can move around the stage but so can the enemies. The enemies are using a pathfinding system that uses navigation mesh. This navigation mesh is created dynamically when the game runs. Player can destroy the tiles of the stage. The tile destruction triggers the recalculation of the navmesh. The recalculation itself is a pretty heavy operation that freezes the whole game for a second or so. What I'm pretty much asking is if there is an async functionality for heavy functions/operations that are triggered from the render loop. Or what is the best way to handle these situations? Quote Link to comment Share on other sites More sharing options...
jerome Posted April 24, 2017 Share Posted April 24, 2017 webworkers ? davrous 1 Quote Link to comment Share on other sites More sharing options...
davrous Posted April 24, 2017 Share Posted April 24, 2017 Yes the only option is Web workers Quote Link to comment Share on other sites More sharing options...
adam Posted April 25, 2017 Share Posted April 25, 2017 Does the pathfinding system freeze the game when there is only one enemy using it? If not, I'd simply limit the amount of times you can call the pathfinding function per frame. edit: OK, I'm seeing that just the recalculation of the navmesh freezes the game. You probably are going to need to use webworkers. 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.