Jump to content

How to not freeze render loop when doing heavy operations


Recommended Posts

Just a quick question; how to not freeze the render loop when doing "heavy" operations?

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?

Link to comment
Share on other sites

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.


OK, I'm seeing that just the recalculation of the navmesh freezes the game.  You probably are going to need to use webworkers.

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...