#ISystem will not Execute on Instantiated Entities

1 messages · Page 1 of 1 (latest)

limpid flint
#

I've been struggling with this for hours and haven't found any solutions online. I've probably missed a tiny step here somewhere.

I have 2 systems in my game right now. A Spawner system who's only purpose is to spawn an empty game object prefab (Entity) in the SubScene and attach the necessary components to it for it to 'construct' itself (Mesh, gameplay data etc)

The second system is that Initialisation System.
The first one as I said works fine, the empty Entity gets instantiated correctly with the correct components.
I've also confirmed it has the correct Aspect related to it.

However, my IJobEntity will not execute on the Instantiated Entity.

The 'Execute' function itself is expecting;

        [BurstCompile]
        public void Execute([ChunkIndexInQuery] int sortKey, PlayerClassAspect classComponent)

And have confirmed that the Entity does have the PlayerClassAspect attached to it in the inspector.

But it just won't execute. I've also tried replacing the Aspect with just one of the components inside it and still nothing.

For the record the scheduler looks like this;

    [BurstCompile]
    public void OnUpdate(ref SystemState state)
    {
        EntityCommandBuffer.ParallelWriter ecb = SystemAPI.GetSingleton<EndSimulationEntityCommandBufferSystem.Singleton>()
                                                    .CreateCommandBuffer(state.WorldUnmanaged).AsParallelWriter();

        state.Dependency = new InitialisePlayerJob()
        {
            ecb = ecb
        }.ScheduleParallel(state.Dependency);
    }

BUT, if I don't instantiate the Entity and instead drag the prefab into the subscene via the editor the Job executes. Is there something I'm missing with how the ECB Instantiates an Entity and for some reason the System isn't detecting these instantiated copies?

Link to Code (Spawning System - working, And the INit System - not working): https://paste.myst.rs/vv0ofe0y

floral wasp
#

This would be a lot easier to read if you formatted the !code

untold compassBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

limpid flint
#

I wanted to minimize the amount of code I added (just to avoid huge walls of text0 but if you need more context/code lmk 🙂

floral wasp
#

I can't see anything wrong with the code, and I don't think there are differences in ecb instantiated entities. I imagine there's something else going on

#

You can link the whole code via a service mentioned in the bot post

#

It'd be worth looking at the queries listed in the Systems window, which one isn't being met, and trying to figure out why

limpid flint
#

Yeah I had a look atthat recently, it looked fine, all the components were present, it just didn't show any matching Entities. Yet in the System window it said 1 Entity (but no link to which one, and anywhere else it suggested there was 0 entities)

tough bobcat
tough bobcat
floral wasp
#

I would presume so!

limpid flint
#

Yup, I did try not using aspects and only using one component (with and without the tag) and still doesn't work

faint shard
#

Can you verify that the OnUpdate() method which schedules the job is running at all, under the conditions where it looks like the job isn't running?

limpid flint
#

OnUpdate which is scheduling the job is definitely running, I've added breakpoints which have been hit.

limpid flint
#

Tertle (not tagging direclty to avoid spam xD ) gave the answer in the general Discussion thread.

I needed to add a line;

state.RequireForUpdate<StartingPointProperties>();

To OnCreate and it fixed everything because I was disabling the system immediately

Because the Subscene loaded async, the System would run the first OnUpdate (where it disabled itself) but the StartingPointProperties had not yet loaded in the subscene. By the time the subscene had loaded the Onupdate had already ran and disabled itself.

And the reason there was a 'spawned' Entity with all the correct components and tags but it wasn't executing the Job is because it was the Prefab entity.
Prefabs are spawned via 'GetEntity()' calls and are invisible and don't affect the Jobs/Systems etc.

The above line means that the OnUpdate will wait for the StartingPointProperties to be loaded into the Subscene before it runs.