P
P
Pavel2018-11-11 13:25:00
Unity
Pavel, 2018-11-11 13:25:00

Why is the component duplicated in the ECS filter?

I made my elementary system on the new unityECS.
The system looks for entities like this:

public class MovementSystem : ComponentSystem
{
    public struct Filter
    {
        public Transform m_Transform;
        public MoveComponent m_MoveComponent;
    }

    protected override void OnUpdate()
    {
        var entities = GetEntities<Filter>();
        Debug.Log(entities.Length);
    }
}

Judging by the debugger , for some reason the system is looking for another filter, where there are 2 MoveComponent components

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel, 2018-11-11
@youkerni

The problem was not in the place where I expected to see it.
The matter is that I hung up the given component (MoveComponent) on object in runtime.
Because of this, he was not registered in the MovementSystem.
I will look for a way to solve the problem, after which I will supplement the answer.
UPD. For those who are interested: it was necessary to register the newly created Entity in the EntityManager.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question