Jump to content

Regarding World::Update()


StOneDOes
 Share

Recommended Posts

I'm not sure I understand the documentation for this function World::Update(). The first param is:

frequency    number of updates per second

I would have thought that this would not be necessary, rather you would just call this function on each game frame? Think of a game server where you are essentially simulating the world, and likely capping the FPS to a suitable amount - lets say 100 frames per second. Do I call world->Update( 100 ) in some arbitrary place, or do I just called world->Update() on each frame, which is already capped out at 100 frames per second by some thread sleeping code that already ran in the given iteration of the game loop? What happens if I call world->Update( 100 ) on each game loop iteration?

Link to comment
Share on other sites

Ok thanks for the repply, but how is it running in its own thread if I'm calling the Update() function? I guess this begs the question, of what happens if I do not call World::Update()?

I'm not sure that this will be suitable for a game server, unless I don't understand correctly. I need to be able to simulate/update the world on command, and essentially pause simulation when I want, so that I can rewind play for things like lag compensation. If objects are still being moved around the world while I'm doing hit calculating then this would end badly. I hope I'm just misunderstanding here. Unless @Josh can you please provide a breakdown of how threads are handling things in the breakdown, thanks

 

Link to comment
Share on other sites

From my understanding World::Update do update physics, calls components Update() methods, etc.

There are undocumented methods Update() and Resume() for World, which probably is what you you need to be sure that nothing will happen even without calling Wolrd::Update().

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.

Guest
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.

 Share

×
×
  • Create New...