Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

ECS - Rebuild of Unity's upcoming - Entity Component System - FREE

Discussion in 'Scripting' started by Spy-Shifty, Nov 5, 2017.

  1. Juande

    Juande

    Joined:
    Nov 20, 2012
    Posts:
    16
    Hmmm... That's weird. I checked twice the pull request I made to the project before sending it. I'm going to take a look at it.
     
  2. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    Should be fixed now! Thx!

    If you have some questions/ hints, please feel free to ask/tell me :)

    I'm happy about any feedback
     
  3. Juande

    Juande

    Joined:
    Nov 20, 2012
    Posts:
    16
    There's the same problem again.

    upload_2017-12-13_13-46-22.png

    But now I think I know why it's happening.

    The RotationSpeedComponent is kept, but the references to the other scripts are lost since there's no .meta file included with the files ECSTransform.cs and GameObjectEntity.cs. The .meta file holds the guid of each file, so when there's no .meta file, Unity creates a new .meta file and assigns a new guid. That's why the prefab has those two component missing.

    You could include the .meta files for all the content of the folder ECS/Unity

    That's why my pull request and your last commit didn't fix the issue.

    This article about .meta files in Unity is interesting:
    https://blog.forrestthewoods.com/managing-meta-files-in-unity-713166ee3d30
     
    Last edited: Dec 13, 2017
  4. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    Well thats right :D

    I have a svn repos for the ecs project (better integration into my other game project svn repos...) So i just prepair each git upload by hand :/ I should also use a git client...
     
  5. Juande

    Juande

    Joined:
    Nov 20, 2012
    Posts:
    16
    The first example has something weird. Can't find the "Systems" on the Hierarchy. Has this behaviour been replaced on newer versions so the systems aren't on the hierarchy anymore?

    upload_2017-12-13_16-34-16.png
     
  6. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    I tested this for 10 minutes only, but if I recall, you had to open setup or something first (there is a new item next to windows)
     
    Juande likes this.
  7. Juande

    Juande

    Joined:
    Nov 20, 2012
    Posts:
    16
    Great! I didn't know that I had to activate the Visual Debugging. Now it makes sense.
     
  8. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    Sorry for the confusing text :D
    I'll write it more clearly :)

    The git hub documentation is also obsolete... I'll need to update this too

    Maybe some one have some small example projects and want to share it for newbies. That would be great :)
    I'haven't the time for it. Cant work fulltime on it...

    Great thanks to all the supporter
     
  9. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    By the way, setup fails on a Mac 2017.2.0p1 -- there is no unityRegistryKey --> this returns null
    Code (CSharp):
    1.     [MenuItem("BrokenBricks/ECS/Setup")]
    2.     private static void SetupECS() {
    3.         try {
    4.             Debug.Log(Registry.CurrentUser.OpenSubKey(unityRegistryKey));
     
  10. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
  11. scvnathan

    scvnathan

    Joined:
    Apr 29, 2016
    Posts:
    75
    Hey spy-shifty, since Unity will be open-sourcing their ECS framework do you have any plans to contribute to it? Maybe propose some of your ideas that you're using in your own framework?
     
  12. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    Last edited: Dec 14, 2017
  13. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546

    Why not.
    I like Unity's ecs and C#Jobsystem...
    The reason I developed my ecs was that I can't wait for Unity's one :D
    And it should be as close as possible to Unity's, so that you can replace mine with Unity's later on(in the best case)

    We all can learn from each other.
    Why not helping :)
     
    scvnathan likes this.
  14. Juande

    Juande

    Joined:
    Nov 20, 2012
    Posts:
    16
    I just submitted a new pull request that checks for the UnauthorizedAccessException when doing the Seput/Uninstall from the BrokenBricks menu. And display this message in case Unity can't copy or delete the template files. It also adds checks for exceptions when Uninstall.

    upload_2017-12-14_18-33-50.png
     
    Spy-Shifty likes this.
  15. scvnathan

    scvnathan

    Joined:
    Apr 29, 2016
    Posts:
    75
    Cool :) Would be nice too if there was a migration guide in the future for people using this system.
     
  16. Micz84

    Micz84

    Joined:
    Jul 21, 2012
    Posts:
    448
    It would be nice if you would show how to use it in input output situations. Entitas has reactive systems, does your solution have anything like that?
     
  17. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    Ok yes I'll do this next time

    What do you want to develop?

    You can use the event system
    You have access to multiple events for ComponentArrays, ComponentGroups, and ComponentSystems

    So you can recognize component changes or adding, removing entities from and to groups or systems

    Take a look at this post:
     
    scvnathan likes this.
  18. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    Hi all.

    Hope you had a merry Christmas!


    I've added a native support for Unity Components *
    It is no longer necessary to manually add ECSTransform,... to a game object.

    What does it means:
    If you have a Gameobject that is available in the ECS than it adds automatically a TransformComponent / ECSTranform to it. This works also for all the supported components (see below)

    *Supported components:
    TransformComponent - Transform
    RigidbodyComponent - Rigidbody
    AnimatorComponent - Animator
    ColliderComponent - Collider
     
    Last edited: Dec 27, 2017
    Juande likes this.
  19. Juande

    Juande

    Joined:
    Nov 20, 2012
    Posts:
    16
    That's great news!

    I was studying your code line by line (I want to know exactly how it works in order to use it properly).

    There's some public misspelled method names like for example "Unsubscripe", "Subscripe" on the ECSEvent.cs file. Are they made like that intentionally? I can make a pull request fixing all the misspelled names taking advantage that I'm reviewing all the files, but that will break the code on existing projects. What are your toughts about this?
     
    Spy-Shifty and Peter77 like this.
  20. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    Oh well thank you!

    Yeah I'm happy about the help of the community!

    I believe this is a minor problem and the changes should be fixed fast by the user... especially if you have a good IDE like visual studio.

    So please go ahead and create a pull request!
     
  21. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    Hi,
    I just wanted to play around with it and downloaded the latest version into a new project.

    Issues on Mac, 2017.2:
    Destination directory not found: /Applications/Unity\Editor\Data\Resources\ScriptTemplates
    PlayerSettings Validation: Requested build target group (2) doesn't exist; #define symbols for scripting won't be added.
    UnityEditor.PlayerSettings:SetScriptingDefineSymbolsForGroup(BuildTargetGroup, String)
    ECSSetup:EnableVisualDebugging() (at Assets/ECS/Unity/Editor/ECSMenus.cs:107)
    2 missing scripts, Game Objects Entity, ECS transform (although this would be added automatically with the auto add
    NullReferenceException: Object reference not set to an instance of an object
    ECS.ECSColliders.Awake () (at Assets/ECS/Unity/Components/ECSColliders.cs:22)
    UnityEngine.GameObject:AddComponent()
    ECS.GameObjectEntity:AddECSComponents() (at Assets/ECS/Unity/GameObjectEntity.cs:41)
    ECS.GameObjectEntity:SetEntity(Entity, EntityManager) (at Assets/ECS/Unity/GameObjectEntity.cs:60)
    ECS.UnityEntityManager:InstantiateWithGameObject(GameObject, NativeArray`1, NativeArray`1) (at Assets/ECS/Unity/UnityEntityManager.cs:115)
    ECSExample.GameObjectExample.PrefabSpawner:Start() (at Assets/Example/GameObjectExample/PrefabSpawner.cs:20)

    Hope you can look into this. I will post other findings as I play with it...


    edit:
    This fixed the collider null ref
    Code (CSharp):
    1.     public class ECSColliders : ComponentWrapper<ColliderComponent>{
    2.         private void Awake() {
    3.            
    4.             if(TypedComponent.collider == null) {
    5.                 TypedComponent.collider = gameObject.GetComponents<Collider>();
    6.             }
    7.  
    8.             //if(TypedComponent.collider.Length == 0) {
    9.             //    TypedComponent.collider = gameObject.GetComponents<Collider>();
    10.             //}  
    11.         }
     
    Last edited: Dec 31, 2017
  22. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    This can be ignored

    Please test it. Unfortunately I can't do that, I don't have a Mac

    Other issues should be fixed now!
    Thank you for reporting

    I also fixed typing errors
    Subscripe -> Subscribe
    Unsubscripe -> Unsubscribe

    This update can break your project.


    I also added a removing event that is called befor a component, entity will be removed!


    Happy new year!
     
    Last edited: Jan 1, 2018
  23. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    Cool. Happy New Year, too. I plan to use your system for a game for learning purposes. If I manage to dedicate some time to it, I can also help fixing things better...

    I like your framework - well done. I will likely get in touch via PM or forum here, to understand some best practices with the ECS model, ie how to handle and distribute input events in a multiplayer setting, etc.
     
    Spy-Shifty likes this.
  24. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    Hi there,

    I just spend an hour on this and have the following discoveries :)

    1. I am struggling to come up with the "right" components and systems - this has nothing to do with your implementation, but I did not find a good resource that shows a good game design pattern ECS (the examples I googled are too simple)

    2. The installation of the script templates is still broken on MAC (at least for 2017) - it is easy to fix though...the right folder is "string destTempFolderPath = @"/Applications/Unity/Unity.app/Contents/Resources/ScriptTemplates";

    3. Although, I did not really spend any time looking at your framework beyond the examples, a little bit better documentation would be useful
    • Basic documentation of all API functionality - just a one line example of usage & a one line description (i.e. things like post #40 are easily missed)
    • Is it possible to use "queries" to inject components, i.e. select all entities that have a "player tag component" but not a "timed effect component"
    • what are the pro / cons of using a class vs a struct
    • should the wrapped components only be used for development & not for release?
    • is there a way to update only one variable of a struct, i.e. (struct Position {float x,y,z}) - can I only update say x or do I have to always create a new Position (which means, I have to read the position first to get the other values)
    • why is it possible to set transformArray.transform.rotation = value directly (Rotation example) and not here: entityManager.SetComponent(floats.GetEntity(i), new FloatComponent(floats.value + 1)); (Beginner example)
     
  25. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    Well ECS should be developed by a top down approach (from a generic case to the specific case). So you should think: what is the most generic case that an entity should do / have. Components should be as small as possible and systems should do only on thing e.g. update position, detect hits, etc.

    You should always think of: entities are defined by there components. You don't have an player entity or an enemy entity or something like that. You have only entity with a player component. If you want to interact with other systems you can create a component with an ECSEvent<T> property. A System can call that event from the component an other system listen to this event. I've implemented a collision detection this way.

    By the way, you shouldn't use ECS for Menus! There are better patterns for that!


    Thank you I've updated the source on git!

    Well I've to do this yes but I haven't enought time. So I'll do this step by step.

    No you can't query it this way.

    please read this post #3

    No you can use it anyway!
    It's a matter of performance and userfriendlieness.

    Please read the posts around this post #35

    I can help you more if I know what you wanna build.
     
    Last edited: Jan 4, 2018
  26. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    Thank you for your response - I have sent you a PM to keep this thread on subject
     
  27. BlankMauser

    BlankMauser

    Joined:
    Dec 10, 2013
    Posts:
    138
    I'm extremely curious about your ECS. I've been trying to follow a data-driven design and I'm wondering if I'm perceiving it correctly.

    Does this mean I can use ECS to render particle system components and other unity components without the need of creating gameobjects?

    Would ECS be useful for example, spawning 100s of bullet objects that just need to move and detect collision? And then do X function upon collision? Or is object pooling better for that?

    What about networking? Is it easy to sync entities over a network and despawn/spawn large amounts of them quickly in a simulation? Or does Object Pooling again beat that in performance?

    If you have any insight to these questions I would love to know!
     
  28. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    You can't use Unity Components without GameObjects! But you can use the graphic api from unity to render your objects from ecs.
    https://docs.unity3d.com/ScriptReference/Graphics.html


    Yes, if you render the bullets whith the graphic api from above. For collision: you have to write your own collision detection system. You don't need object pooling anymore!

    Entities are just states and should be easy to sync. You'll need a concept for RPC's and events.
    You neet to write your own logic for that.

    In my game:
    I just use GameObjects and ECS for logic. So I can use PUN or UNET for synch. Messages will be handled by a component which triggers events to systems.

    So all my Logic is in Systems and Data is on my GameObjects.

    If you want to know more, let me know!
     
  29. BlankMauser

    BlankMauser

    Joined:
    Dec 10, 2013
    Posts:
    138
    Wow that all sounds really interesting! In the new ECS Unity is making you can use any component though right? Main reason I'm asking is I'd want to use particle system components that don't need gameobjects since they just need a position.

    And since entities are states it would be easy to save the gamestate right? I'm curious is the ECS much faster than pooling or simply much faster than instantiating?

    Thanks for answering my questions I think I'm definitely going to check this out now that 2018 is in beta.
     
  30. Skolwind

    Skolwind

    Joined:
    Aug 28, 2014
    Posts:
    8
    I've been experimenting with ECS and I am struggling with designing ECS systems.
    Let's say I have player and enemy entities with Position component, and two systems which move them: PlayerInputSystem and EnemyMoveSystem.

    I need a way to distinguish between player and enemy entities, I see several options:
    1. Manual filtering - make boolean flag isPlayer, inside the system check weather or not specific entity is a player
    2. Use Groups - make components IAMPlayer && IAMEnemy, make two groups: Position with IAMPlayer and Position with IAMEnemy
    3. Instead of Position component create PlayerPosition and EnemyPosition components
    4. Use different contexts, one for enemies and another for player
    5. Combine 2. and 3. - Create NextPlayerPosition and NextEnemyPostion components and create two groups(NextPlayerPosition && Position and NextEnemyPostion && Position)
    First approach will degrade performance and in general seems very inconvenient.
    3 & 4 are bad if some other systems needs Position component and does not care whether entity is a player or not.
    2 & 5 are bad if you have different enemies which move differently (if you need to distinguish not just between player and enemy but between player, enemy1,.., enemyN )
    second would be good if you did not need to create two components (if GroupMacher supported NOT operation, I could say give me group with Position && not IAMPlayer), maybe it's not a big deal, and second is the winning option?

    Is there a "right way" to do this?
     
  31. Juande

    Juande

    Joined:
    Nov 20, 2012
    Posts:
    16
    I would say the 2nd one is one of the best choices. I've seen components like "isPlayer", "isEnemy", "isEnabled", etc.
    If you have enemies that move different, you should have one system for each type of enemy movement. Remember that each system must do just one specific thing.

    Option 1: isPlayer shouldn't be on the Position component. It should be on the IsPlayer component. And since the IsPlayer component defines a Player entity, there's no need for the isPlayer variable.
    Option 2: It's the winner. IMHO.
    Option 3: You shouldn't duplicate data types. The thing in ECS is to reuse.
    Option 4: That could work, but I don't think that's semantically correct since a player and the enemies share common components.
    Option 5: The same that on Option 3. Don't duplicate. Try to reuse.

    About if there is a "right way"... That would take time to test the complexity that each option adds to the code, and the performance you get using each one. I personally would do what I described on this post. Note that I haven't even made any game using ECS yet, so I could be wrong.
     
  32. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    @Skolwind

    Hi - I am also new to ECS and have the same struggles you have. The best in my view is to just focus on getting the output done, not worrying about performance. Just ECS design driven you will likely change things around multiple times (I did and likely will in the future) - I was also nagging @Spy-Shifty about supporting OR and NOT for querying. I am now thinking of it does more good than evil - still undecided.

    I have very little time at the moment but if I get something like a prototype ready, I am happy to share my structure / approach. I googled a while but did not find anything that was not super basic.

    Would be great if the ones experimenting with this to share a bit here...I feel the ECS system is quite cool and I could be using this more in the future

    Ps: I am using an old abandoned project of mine as a test for ECS- simple 2D racing game
     
  33. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    ECS need to be build from top down not from bottom up. Try to generalize things.

    So what does all the entities have common?
    Well they need a position and they need an information to handle the next positioning

    So you could do the following:

    Create a PositionComponent, that just defines the position of an entity
    and a VelocityComponent, that defines the movement direction and speed

    So you devide and conquer the complexity
    The MotionSytem needs only these two informations
    (Velocity and current position to calculate the next in combination with the deltaTime....)

    Now you can create an EnemyComponent and an PlayerComponent, this is completly legitimate!
    You can build two different systems to handle the VelocityComponent for enemies and players, depending on the PlayerComponent and the EnemyComponent.

    Conclution
    You have a MovementSystem that handles all entities with velocity and position components with out the need to know who drives the VelocityComponent.

    And you have other Systems who handles entities with a VelocityComponent depending on the entity state.


    So the result is:
    Loose coupling between systems and systems as well as components.
    This way, it is easy to add new features without to rewrite all systems.

    What you can do with this design concept:
    Well imagine your want that the player could switch between characters and controll them (RPG Game). So the only thing you need to do for this is:
    Remove the EnemyComponent from Entity B and add the PlayerComponent to it and vice versa for Entity A.

    Hope this will help a little bit :)
     
    HouinKyouma27 likes this.
  34. JohnHudeski

    JohnHudeski

    Joined:
    Nov 18, 2017
    Posts:
    126
  35. Skolwind

    Skolwind

    Joined:
    Aug 28, 2014
    Posts:
    8
    Thanks everyone for your replies, this cleared things up for me.
     
  36. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
  37. JohnHudeski

    JohnHudeski

    Joined:
    Nov 18, 2017
    Posts:
    126
    I updated the thread but I so rust that i dont think it makes sense
     
  38. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    New Update available!

    I've changed the behaviour of EntityManager.RemoveComponent and EntityManager.DestroyEntity.
    Now it will remove components and destroy entities after Update of all system was called.

    I also added EntityManager.RemoveComponentImmediate and EntityManager.DestroyEntityImmediate
    which behaves like the old implementation.

    I also revised the ecs event system (renamings and other things)

    Currently I'm working on the documentation. Stay tuned :)
    Happy weekend!
     
    Stardog likes this.
  39. vdwtanner

    vdwtanner

    Joined:
    Jun 10, 2015
    Posts:
    8
    Thanks for all the hard work Spy-Shifty! I downloaded your code yesterday and have been trying to get my feet wet, so I'm excited for the documentation that you are working on :)

    I did have a question about use cases for ECS though. I noticed that (profiling on my machine) the beginner example that just increments 1000 floats every frame takes about 1.28 ms, whereas 1000 normal Unity MonoBehaviors that increment a float in their Update function only takes about .29 ms. Should we be avoiding writing to entity components when using ECS? I'm very new to this concept, so my apologies if that is a very noobie question lol.

    Thanks!
     
  40. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    Wow well thank you for reporting that issue.

    Well normaly this should be very fast! I'll look where the problems come from.
     
    Last edited: Jan 15, 2018
  41. vdwtanner

    vdwtanner

    Joined:
    Jun 10, 2015
    Posts:
    8
    Awesome, thanks! My initial guess was that it had to do with recreating the components. I tested just setting the float on the array created from injecting the tuples, and that was nice and fast (~.05ms if I remember correctly), but obviously not very useful if you need to do more than alter the local (system) state of the component.
     
  42. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    Hi all,

    I actually try to fix the accesstime problem of the SetComponent method. Well this is really difficult. Because its more or less a core problem of the api.

    I have to search for a different datastructure to solve this problem.
    I also studying one more time the Video of Joachim from Unite 2017

    Maybe someone has a good approach.
     
  43. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    Ok I beleave I have a good I idea how to deal with this problem.
    But it will take some time. I'll use it as a chance to clean up some stuff and to add docs to the function.

    So stay tuned and look forward to the next verion. Maybe this weekend but I can't promise :)
     
  44. Artanic

    Artanic

    Joined:
    Nov 26, 2012
    Posts:
    9
    How would something like an RPG ability/spell work in this system? Would there be an entity with components to represent that ability and a component on the player that is an array of abilities?

    Also how would you handle one off actions like a player opening a chest. Most of the examples of ECS always focus on continuous looping updates to all Entities which normally only occur in a small % of game logic.
     
  45. Filtiarn_

    Filtiarn_

    Joined:
    Jan 24, 2013
    Posts:
    173
    Let me start off by Saying thank you for making this. Its been fun to use. I'm confused about one thing though. Under Debug System Behavior it says I have 9 Update systems. but Below in OnUpdateSystems it shows I have 3(Which I do). I'm confused.

    Here is code for where I add Systems

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using ECS;
    5.  
    6. public class Main : ECSController<UnityStandardSystemRoot, UnityEntityManager>
    7. {
    8.     protected override void Initialize()
    9.     {
    10.         AddSystem<GridSystemInitializer>();
    11.         AddSystem<GridSystemGenerator>();
    12.         AddSystem<GridSystemDebugRenderer>();
    13.         AddSystem<GridSystemCleanuper>();
    14.     }
    15. }
    Here is a example System which is the one I use to render the grid for debugging

    Code (CSharp):
    1. public class GridSystemDebugRenderer : ComponentSystem
    2. {
    3.  
    4.     [InjectTuple]
    5.     private ComponentArray<GridComponent> grids;
    6.    
    7.     private List<Matrix4x4> transforms;
    8.  
    9.     public override void OnUpdate()
    10.     {
    11.         for (int i = 0; i < grids.Length; i++)
    12.         {
    13.             GridComponent grid = (GridComponent)EntityManager.GetComponent(grids.GetEntity(i), typeof(GridComponent));
    14.             EntityManager.SetComponent(grids.GetEntity(i), OnExecute(grid));
    15.         }
    16.     }
    17.  
    18.     private GridComponent OnExecute(GridComponent grid)
    19.     {
    20.         //Initalize if Null
    21.         {
    22.             if (grid.mesh == null)
    23.                 grid.mesh = GridHelper.CreateCubeMesh(0.05f);
    24.  
    25.             if (grid.material == null)
    26.             {
    27.                 grid.material = new Material(Shader.Find("Custome/Instanced/Unlit"));
    28.                 grid.material.color = Color.cyan;
    29.                 grid.material.enableInstancing = true;
    30.             }
    31.  
    32.             if (transforms == null)
    33.                 transforms = new List<Matrix4x4>();
    34.         }
    35.  
    36.         //Update if grid is dirty
    37.         {
    38.             if (grid.isDirty)
    39.             {
    40.                 transforms.Clear();
    41.                 for (int i = 0; i < grid.gridNodes.Length; i++)
    42.                 {
    43.                     Matrix4x4 matrix = new Matrix4x4();
    44.                     matrix.SetTRS(grid.gridNodes[i].worldPosition, Quaternion.identity, Vector3.one);
    45.                     transforms.Add(matrix);
    46.                 }
    47.             }
    48.         }
    49.  
    50.         //Render with Draw Mesh Instance
    51.         Graphics.DrawMeshInstanced(grid.mesh, 0, grid.material, transforms);
    52.  
    53.         grid.isDirty = false;
    54.  
    55.         return grid;
    56.     }
    57. }
    58.  
     

    Attached Files:

  46. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    954
    Let's say you already have something like a playerComponent on an entity. If you put a ChestOpenedComponent on the same entity, an engine with these tuples can pick it up and process it.
     
  47. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    This might be a bug! Can you open a issue on git thx :)

    For your ability... well you can do it on multible ways. You can create a component for each ability. Or you can create a component that holds a list of abilities for you.
    Try different ways and choose the one better for your needs :)
     
  48. Filtiarn_

    Filtiarn_

    Joined:
    Jan 24, 2013
    Posts:
    173
    Thank you so much for. Ill open a issue on git right now.

    Edit : I wrote a fix for it in the issue. https://github.com/Spy-Shifty/BrokenBricksECS/issues/24
     
    Last edited: Jan 18, 2018
    Spy-Shifty likes this.
  49. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546

    Well I tryied a different approach. But it seams not to work much much better. Its slightly better but I'm loosing maintainability of the framework. In this approach I used some lookup tables to handle array access.

    Even without searching... it will take several time to update 100.000 enitties.

    The old approach took for the same test 27ms, the new approach 22ms on my computer.
     
  50. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    So what is the conclusion?
    1. if you want to use an ECS for speed purposes today - look for an alternative one that can already today provide a speed boost over the standard unity approach?
    2. if you want to use an ECS that has a very similar API to the anticipated Unity ECS and speed is not a key driver - use your ECS?
    I am toying with this at the moment and for me later compatibility to the Unity ECS would be more important that speed.
     
    Spy-Shifty likes this.