StOneDOes Posted January 19 Share Posted January 19 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? Quote Link to comment Share on other sites More sharing options...
Dreikblack Posted January 19 Share Posted January 19 Game logic runs in own thread with 60 Hz by default. This param can change it. FPS can be way higher, but game logic would still run with this stable frequency. Most likely internally at the very end of what Update is doing sleep with left time till next game cycle iteration happens. 1 Quote Link to comment Share on other sites More sharing options...
StOneDOes Posted January 21 Author Share Posted January 21 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 Quote Link to comment Share on other sites More sharing options...
Dreikblack Posted January 21 Share Posted January 21 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(). Quote Link to comment Share on other sites More sharing options...
Josh Posted January 24 Share Posted January 24 This parameter is intended to allow you to change the update frequency of the game, so you can do things like run physics at 90 updates per second, which may be appropriate for some driving games to perhaps twitch shooters. I do not recommend using this parameter as it is not used frequently and might not work totally correctly. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted January 24 Share Posted January 24 On 1/21/2025 at 12:17 AM, Dreikblack said: 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(). World::Pause() and Resume() only affect the world's clock, which updates once per call to World::Update. This is meant for pausing a game when a menu system is opened, or something like that. This will "trick" World::GetTime() into not noticing the paused time when the menu was open. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
StOneDOes Posted January 26 Author Share Posted January 26 So would you suggest just calling World::Update() on each server frame, as you do on the game client loop? Quote Link to comment Share on other sites More sharing options...
Solution Josh Posted January 26 Solution Share Posted January 26 If the server is actually running the game, yes. Quote My job is to make tools you love, with the features you want, and performance you can't live without. 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.