Getting started with the Unity ECS Framework (i)

Source: Internet
Author: User

ConceptECS is an acronym for three concepts, namely Entity-component-system.
Entity Represents an independent individual.
Component An individual's data, and how it interacts with the game world.
System The component of the entity on the system is continuously processed and each system has a separate thread.
ExampleSuppose we have a drawing function, which is a system that goes through all of the entity with the physical and visible components and draws it with the information provided. The visible component contains information about what the entity should look like, while the physical component provides a place to draw. And then the collision detection as an example. The system iterates through all the entity that owns the physical component, then detects the collision and generates the corresponding event when needed. the difference between ECS system and traditional OOPIn an OOP system, the state of an object is encapsulated in an individual, and the object provides some means to manipulate these states indirectly (Code Daquan: Abstract data types). There's nothing wrong with such a system, but from the perspective of game development, when you've packaged everything up and well-structured, the game designer suddenly says he needs a completely different function, and the general disaster starts here. We now know that the ECS system is characterized by separating the State (provided by component) from the behavior (by the system systems), and the component is independent, We can add new features without modifying any code by adding new component and system separately, which is the idea of the strategy pattern in design mode. the ECS System (ENTITAS) Designed for unityIn Unity's traditional programming, we use Monobehavior to write the core idea of the game: separating the data from the behavior.
    • In unity, we put the Monobehavior component in the Gameobject. However, unlike the entity system, component is designed to be attached to the entity.
    • Use a pool to contain all the entity. Through pool we can see all the entity.
    • We can group the entity, which is called Group. We can then distinguish between different group by the specified rules,
    • This rule is called Matcher, which makes it easy to get the entity of the specified type quickly by Matcher.
RELATED LINKSEntitas-entity System Architecture with Unity-unite Europe Https://www.youtube.com/watch?v=Re5kGtxTW6E&featu Re=youtu.begithub entitas-csharp https://github.com/sschmid/Entitas-CSharpEntitas-CSharp Video Tutorial Collection https://github.com /sschmid/entitas-csharp/wiki/tutorials How to understand Data-driven Design https://www.zhihu.com/question/in game development 26775352 Research on ECS design mode in game development 48625257

ThinkingIn fact, this can be seen as a strategic model. In the policy mode, the logic code is encapsulated in the same interface, which allows us to dynamically replace the logic code at runtime and change the behavior of the program. "If you follow the solid principle to write the program, then the design pattern will naturally be written out." Policy Mode"Defines a series of algorithms, encapsulates them one by one, and allows them to be replaced by each other." This mode allows the algorithm to be independent of the customers who use it. --"Design pattern"

Getting started with the Unity ECS Framework (i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.