Hello, so I’ve been working on my game lately and I just witnessed a slight delay that occurs for some of the game objects I have. The objects are rotators, so when X seconds pass, these objects rotate 90 degrees. There are two of these objects I’m watching, and they’re set to rotate at the same interval (every 0.5 seconds) However, I’m noticing at random occurrences they’re actually out of sync quite a bit unfortunately.
I figure this is due to the core game loop, which iterates over all the game objects, checks to see if it isn’t currently updating that game object, and if so, call an Update
method for that object in a new coroutine to not interrupt the current thread for other object updates.
This is a bit puzzling. I worry the delay could get to the point of actually affecting the rotations I set up for these objects before the game even started. (larger the delay, the less and less accurate they’ll be?)
One idea I thought of doing was separating these specific objects into another table, then iterating over that specific table before all the other game objects, in hopes of creating more instantaneous updates for those objects to reduce this delay between them. Haven’t tried this though.
Another question
And since I decided to make a post, I figured I’d throw in another question regarding the yield for my core game loop. I’m currently using a wait()
, mainly because it runs at most 30 times a second, which I feel is more appropriate for updating all these objects. If I migrate over to a more event-based way of yielding, such as Stepped:Wait()
, that should run at most 60 times a second, and this could potentially cause performance issues as to everything running twice as frequently…really not sure as to what the ideal method for yielding the core game loop would be; as it’d crash obviously with no yield in there at all.
Thanks for reading