Timeline for How does entity communication work?
Current License: CC BY-SA 2.5
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 26, 2017 at 16:44 | comment | added | Danny Yaroslavski | This is fairly simple. It's a matter of whether to handle an event right away or wait to defer it. The system that handles the hit computation would instead defer it to its update cycle. On receiving an event, it would only store the "hit". Then it would receive the other "hit" and store it too. Then when it's the system's turn to run later in this frame, it'll process all of the hit events, and propagate kill events for those entities who end up with 0 health. | |
Aug 20, 2015 at 13:35 | comment | added | Tara | This problem is insanely easy to solve. Just apply the damage to each other in the message handlers or whatever. You definitely shouldn't flag the player as dead inside of the message handler. In "Update()" you simply do "if(hp <= 0) die();" (at the beginning of "Update()" for example). That way both can kill each other at the same time. Also: Often you don't damage player directly, but through some intermediate object like a bullet. | |
Dec 17, 2014 at 1:56 | comment | added | v.oddou | I think at the frame levels, most game implementations are simply unfair. like Kylotan said. | |
Aug 31, 2011 at 22:58 | comment | added | Pablo Ariel |
I use 2 calls so I call Update() to all entities, then after the loop I iterate again and call something like pEntity->Flush( pMessages ); . When entity_A generates a new event, it is not read by entity_B in that frame (it has the chance to take the potion too) then both receive damage and after that they process the message of the potion healing which would be the last in the queue. Player B still dies anyway as the potion message is the last in the queue :P but it may be useful for other kind of messages such as clearing pointers to dead entities.
|
|
Mar 22, 2011 at 20:21 | comment | added | Kylotan | I doubt that most games care about this unfairness because they update so frequently that it is rarely an issue. One simple workaround is to alternate between iterating forwards and backwards through the entity list when updating. | |
Mar 22, 2011 at 7:15 | comment | added | bummzack | You're not really answering the question but I think your answer would make an excellent question itself. Why not go ahead and ask how to resolve such an "unfair" prioritization? | |
Mar 22, 2011 at 0:01 | history | answered | user6237 | CC BY-SA 2.5 |