#Entity spawning on input resulting in Assertion Fault
1 messages · Page 1 of 1 (latest)
turn off burst so you can see your error better
(also you shouldn't be using Entities.ForEach, or use ECBS like that anymore. This code is very dated)
oh your error is you're doing this in a FixedUpdate
but using a non-fixed update ECBS
so if your fixed update runs twice before your playback happens
you're going to create 2x the fireballs and try to remove CastSpellRequest twice
and removing it a second time is what causes your error
i see, i thought that might have been the cause but didnt know why
whats the entities.foreach replacement recommendation?
just standard foreach query right?
RefRO<LocalTransform> localTransform,
RefRO<PlayerComponents.PlayerTag> playerTag,
RefRW<PlayerPosition> playerPosition)
in SystemAPI.Query<
RefRO<LocalTransform>,
RefRO<PlayerComponents.PlayerTag>,
RefRW<PlayerPosition>>())```
like this?
yes
well in your case no
because you're doing a job
should be IJobEntity
IJobEntity replaces Entities.ForEach
SystemAPI.Query replaces Job.With
so something kind of like this?
[BurstCompile]
public partial struct ChaseEnemySpawnerJob : IJobEntity
{
public EntityCommandBuffer.ParallelWriter commandBuffer;
public Entity enemyPrefab;
public void Execute([EntityIndexInQuery] int entityIndex, in LocalTransform localTransform, ref EnemySpawner enemySpawner)
{
Entity enemyEntity = commandBuffer.Instantiate(entityIndex, enemyPrefab);
commandBuffer.AddComponent(entityIndex, enemyEntity, new EnemyMover
{
moveSpeed = 3f,
rotationSpeed = 10f
});
commandBuffer.SetComponent(entityIndex, enemyEntity, LocalTransform.FromPosition(localTransform.Position));
}
}
this is what i do to spawn enemies with a job
yes
alright ill give this a shot thank you
but yeah, underlying problem is just using wrong entity command buffer system
got it working! went with this, thanks!