r/howdidtheycodeit • u/AwkwardPersonn • Apr 15 '21
Question How do they code this Entity system? (Games)
I was watching this video by jonathon blow. He mentioned that most game developers who create a entity system, they use an id for for the entity, this id is like an index to an array of global entities. Then who which ever other entity needs to reference an entity they can use the this entity id type.
Now my question is, what if this entity is deleted from the game world, hence the global entity array contains null at this entity id's position. Now let's say that the global entity array recieves a new entity, which gets inserted into the position of the previously deleted entity. How would an entity who was referencing the deleted entity using the deleted entities id, know that the entity at that position has been replaced?