what is best way to deal with off screen content in RPG game where you can have multiple units ? I currently have time lapsed variable that gets passed to the off screen to objects to update them IE Trees lose leaves, water freezes, fruit ripens / rots but they don't do it until they are on screen again. Now what about the fighters / enemies and their horses? should they still battle and die? Since fighters eat and drink should search for water when they run low? any ideas would be helpful
RPG / RTS game dealing with off screen units?
I always tag my object entities with ENABLE and VISIBLE, when object is ENABLEd it will be updated whether it is drawn on screen or not and after culling all object entities only tag with VISIBLE will be drawn.
When creating the object entities it's up to you to determine whether the object needs real-time update or not and tag it as .IsNPCorNotRelevant.
P S U E D O C O D E :
// Cull to determine if it IsDrawnOnScreen or not
DoCullingOnScreen()
// Determine whether the object need update or not
for each ENTITY
if ENTITY.IsDrawnOnScreen
{
ENTITY.enable = ENTITY.visible = true;
}
else
{
If ENTITY.IsNPCorNotRelevant
ENTITY.enable = ENTITY.visible = false;
else
ENTITY.enable = true
ENTITY.visible = false;
endif
}
endeach
// Update only Enabled entity
DoTheUpdateOnEntities()
// Draw only visible entity
DoTheDrawingAllEntities()
Right I know I can do that most of my other objects don't get updated till they are in view. But I wanted it to be realistic. I guess stopping the enemies from moving when they not on the map could be help a little. My rpg has turn system and 1440 turns = 1 day 1 game turn = 1 minute every day a must drink water or he will start to suffer severe damage to his health at least every 2 days man must eat. For a month to pass by and not to die from starvation makes little sense, and for man who is out food just sitting there makes little sense either when there streams to drink from , fruit to pick , animals to hunt , and shops to buy food and or water at. I guess I answered my question I guess I need some kind of solider AI when they are off screen and update the plants too because if the fruit are there the soliders cannot pick them .
In your case, you just need to interpolate the state of your object, interpolate the object state since you know the initial value and the current values when the object becomes active.
The first choice, for the sake of not complicating game rules and not introducing bugs, is simulating everything exactly in the same way. Offscreen entities are only special because you can cull them while rendering frames.
If entities of a certain type are enough to cause proved performance problems, maybe they can be simulated in a more aggregate and abstract form.
For example, instead of one million fruit, ten thousand fruit trees: fruit ripeness, fruit size, size, number of fallen off rotten fruit etc. can be stored as tree properties rather than fruit properties, then given a random seed and the tree stats the fruit in a tree can be procedurally generated in a reproducible way when the tree becomes visible. If you can see individual apples, you cannot possibly see many apple trees.
A more common example: instead of individual soldiers, units on the battlefield can be a squad (or survivors thereof) that is drawn as a group of soldiers but simulated as a single entity.
Omae Wa Mou Shindeiru
On 5/27/2018 at 10:25 PM, macmanmatty said:I guess stopping the enemies from moving when they not on the map could be help a little. My rpg has turn system and 1440 turns = 1 day 1 game turn = 1 minute every day a must drink water or he will start to suffer severe damage to his health
How is your game organized? RPGs are often very large worlds and only small segments are loaded and processed at a time.
In several games I've worked with, there are three tiers.
The most compute-intensive and difficult tier is being near the player. Everything gets simulated. In your case that would include simulating drinking water.
When they're still in actively loaded zone but far away from the player, they are effectively suspended. When the part of the map is brought back from suspension every item is told it was idle for a large number of ticks. Groups of items are handled as a batch when possible. Game objects are written to handle those large changes and basically assume they were doing all the survival items during that time. They would automatically heal, items would regrow as though they were left alone for that duration, they would randomly have some decay or modification on a few values such as the drinking water you described. There is a small cost when a bunch of things are being revived from suspension, but it can be built to spread the cost across multiple frames.
And when they're unloaded for being too far away, but reloaded back in, anything that wasn't saved is set to initial values, which usually means either a fixed value or randomized along a designer-provided probability curve.