(Sorry for the wall of text. It seemed a good idea to give some context.)
Having completed the conversion of my pathfinding and navigation system, I became a huge fan of the data oriented approach so I decided to start my game over from scratch. I was able to get most elements of it converted to pure ECS, but unfortunately, there are a few important aspects that have to remain MonoBehaviours for now (mostly because of PuppetMaster and Final IK).
I am wanting to try and get things as close as possible to the DOTS way of doing things. Since my NPCs use PM and FIK, I currently just have them as normal Prefabs with a GameObjectEntity, then in ECS I have an Entity for each one which has all of my waypoint, movement, navigation, etc and I was just using CopyTransformToGameObject for the moment to test and what not. Everything works as expected, for the most part.
Before I started over, I had some monitor/manager classs attached to each character (which used to handle storing the waypoints, doing the path finding, handle the movement, etc) and one thing that it did was use a fairly large trigger collider to detect if something is in range to potentially unpin the character and cause it to go into ragdoll, if so, it enables the PuppetMaster solvers and what not so that if whatever did come in range happens to come into contact with it, it is ready to react accordingly, otherwise they stay off so that everything isn’t calculating all the time.
This worked well enough before starting down the DOTS path, but now, it just feels… wrong/bad. Each character walking around with a few fairly decent sized classes, each with it’s own update checking a bunch of things constantly for itself only, running timers, checking distances etc. I very much want to try and use a more DOTS-like approach. So that is mostly what my questions pertain to.
What are some of the best ways to utilize the tools currently available in the DOTS packages with GameObjects/MonoBehaviours (if there even are any)? For example, you use IComponentData, DynamicBuffer, etc in ECS, and you can easily use those things with your systems and jobs, but what might be a good approach to use outside of ECS? Since I can’t throw some IComponentDatas on my MonoBehaviour character and have a system/job that is standing by waiting to do some work on them, are there any systems/tools that I can use which might help in trying to make better use of the memory in which these characters are allocated without them being Entities in the ECS system which would allow me to more effeciently iterate over all of the characters in a similar manner instead of having each one do it itself?
Perhaps instead of each character having the full “character monitor” script on it with all of the various data fields, functions, and update processes in it, I just make a small and simple character class (or more than one to split the characters data up more so it’s not one bigger class wasting cache misses on iterations?) that just has data in it and no functions or is just the fact that it is a GameObject/MonoBehaviour to begin with making it so that?
I suppose that each character that spawns could get added to a list on a MonoBehaviour manager, I could then do a GetComponent on each of them for the particular components that I need and iterate over each one of them as I would in an ECS system using the managers single update method, but would that approach even provide any sort of performance gain over just leaving it as it is now and having each one’s update handle it’s own processes?
Any tips or info in regards to these questions would be appreciated!
Thanks,
-MH