• Breaking News

    ECS Implementation - How should systems communicate with eachother? Hi there, I'm currently implementing an ECS framework and am struggling with the concept of inter-system communication. My ideal ECS model would consist of a single game loop with various systems containing a simple "update" function. This update function would then rip through all the relevant entities (components in my case) and perform some action (e.g. update screen, update component data, etc.) However, I keep running into the scenario where it seems like one system should influence the action of another system. For example: Let's say I have a physics system that updates entity positions and a lifetime system that updates whether or not an entity should continue to be alive. Every game loop, I want to call PhysicsSystem.Update() to update the entity position. I then want to call LifetimeSystem.update() to check if any entities have "died". However, if an entity were to die (as determined by the lifetime system) there would need to be some clean-up action done within the physics system (I use a 3rd party physics engine that you needs to be "cleaned-up" if an entity is removed). So in this case, I need my lifetime system to be able to message my physics system to perform a clean-up action. I've heard of adding "event components" to entities to signal actions. For example, I could have a "collision detection system" that checks for collisions and then adds "collision components" to any entity that has been involved with a collision. A "collision handler" system would then rip through all of the collision components. This seems to work for certain events, but it doesn't work as well for the event I described earlier. In that scenario, the entity would have already been deleted prior to the the physics system being able to read a "death component" to perform clean-up. To solve this problem, it seems like it would make more sense to implement a "death system" that would perform all clean-up associated with an entity. The only thing I don't like about this is that this "death system" would need to be aware of the other systems. This seems to go against ECS. I'm curious to hear about techniques relating to inter-system communication and event handling relevant to ECS. https://ift.tt/eA8V8J

    Hi there, I'm currently implementing an ECS framework and am struggling with the concept of inter-system communication. My ideal ECS model would consist of a single game loop with various systems containing a simple "update" function. This update function would then rip through all the relevant entities (components in my case) and perform some action (e.g. update screen, update component data, etc.) However, I keep running into the scenario where it seems like one system should influence the action of another system. For example: Let's say I have a physics system that updates entity positions and a lifetime system that updates whether or not an entity should continue to be alive. Every game loop, I want to call PhysicsSystem.Update() to update the entity position. I then want to call LifetimeSystem.update() to check if any entities have "died". However, if an entity were to die (as determined by the lifetime system) there would need to be some clean-up action done within the physics system (I use a 3rd party physics engine that you needs to be "cleaned-up" if an entity is removed). So in this case, I need my lifetime system to be able to message my physics system to perform a clean-up action. I've heard of adding "event components" to entities to signal actions. For example, I could have a "collision detection system" that checks for collisions and then adds "collision components" to any entity that has been involved with a collision. A "collision handler" system would then rip through all of the collision components. This seems to work for certain events, but it doesn't work as well for the event I described earlier. In that scenario, the entity would have already been deleted prior to the the physics system being able to read a "death component" to perform clean-up. To solve this problem, it seems like it would make more sense to implement a "death system" that would perform all clean-up associated with an entity. The only thing I don't like about this is that this "death system" would need to be aware of the other systems. This seems to go against ECS. I'm curious to hear about techniques relating to inter-system communication and event handling relevant to ECS.

    from GameDev.net https://ift.tt/2NNIvne

    ليست هناك تعليقات

    Post Top Ad

    ad728

    Post Bottom Ad

    ad728