Replies: 2 comments 5 replies
-
Also, here's how the data from EntitiesBT interact with the rest of the ECS code
|
Beta Was this translation helpful? Give feedback.
-
Take this node as example, you must have both [BehaviorNode("1C695088-A8BE-43C4-B145-6E617825B39A")]
public struct AccessEntity : INodeData
{
public NodeState Tick<TNodeBlob, TBlackboard>(int index, ref TNodeBlob blob, ref TBlackboard bb)
where TNodeBlob : struct, INodeBlob
where TBlackboard : struct, IBlackboard
{
var em = bb.GetObject<EntityManagerComponent>().Value;
var entity = bb.GetDynamicBufferUnsafeRO<Child>()[0].Value;
var value = em.GetComponentData<IntComponent>(entity).Value;
return NodeState.Success;
}
}
public struct IntComponent : IComponentData
{
public int Value;
}
public class EntityManagerComponent : IComponentData
{
public EntityManager Value;
}
public class EntityManagerComponentAuthoring : MonoBehaviour, IConvertGameObjectToEntity
{
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
{
dstManager.AddComponentData(entity, new EntityManagerComponent { Value = World.DefaultGameObjectInjectionWorld.EntityManager });
}
} You can also access component in job as long as you have Chunk and ChunkIndex, but you have to handle There's tedious work to do If you are intend to make Maybe I could write a quick/dirty example of this feature, if you still want to access node entity by using |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm going for an architecture that decouples behavior tree flow from the actions each node performs. This is done by grouping each action (Walk, Attack, Evade, Flank, etc...) into this structure
The Behavior Unit Entity is a Sequence Node, the Start and End Entities are barebones Nodes that write to the Behavior's Entity IComponentData. Custom IComponentData that influence System processing go into the Behavior Entity. In other words, Behavior Unit, Start, and End do all the Behavior Tree stuff, while Behavior does all the action processing using the action's bare minimum required components. This should theoretically avoid using God Entities which would have every single action-related component in the game, but is thwarted by the fact that every time this happens:
where the Blackboard fetches a DataRef, a new instance of that IComponentData is injected into the behavior tree root, instead of the current node. The result is this:
while the nodes themselves have their own copy that they never write to because of this code:
Basically, no matter what I do, all IComponentData used in Tick are injected into the root Entity instead of the current node. If I proceed with this structure, then the root Entity will have dozens upon dozens of different components in different combinations. This would not use chunk space efficiently, and iteration would be clunky and slow. On the other hand, if the IComponentData is injected into the nodes instead, there would be a few, homogenous archetypes with well-utilized chunks, which is ideal.
I understand that the concept of a "blackboard" is that it holds all state, and the blackboard seems to be stored in the root. This would mean that my idea violates the design philosophy of EntitiesBT where Nodes are stateless. Still, I believe my game would benefit from node-specific component storage. Is there a way to have the IComponentData reside in the Node that uses it, instead of the root Entity? If a feature from you is not possible, and I have to do some code wrangling, that's fine as long as it's possible.
Beta Was this translation helpful? Give feedback.
All reactions