using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
namespace Systems
{
public partial class TileSpawnerSystem : SystemBase
{
// Update is called once per frame
protected override void OnUpdate()
{
//EntityQuery tileEntityQuery = EntityManager.CreateEntityQuery(typeof(TileTagComponent));
TileSpawnerComponent tileSpawnerComponent = SystemAPI.GetSingleton<TileSpawnerComponent>();
EntityCommandBuffer entityCommandBuffer = SystemAPI
.GetSingleton<BeginSimulationEntityCommandBufferSystem.Singleton>()
.CreateCommandBuffer(World.Unmanaged);
for (int i = 0; i < 500; i++)
{
Entity spawnedTile = entityCommandBuffer.Instantiate(tileSpawnerComponent.tilePrefab);
entityCommandBuffer.SetComponent(spawnedTile, new TransformAspect()
{
LocalPosition = new float3(i, i, i)
});
}
}
}
}```
When I look at this the entityCommandBuffer.SetComponent shows an error that 'the constraints for type arguments not satisfied'
Anyone have any explanation? I am new to Dots, but I just don't understand this. tileSpawnerComponent.tilePrefab, is also an Entity.
I know the code doesn't make sense, I'm just trying to get it functioning first, then I intend to go in and change what it's actually doing.
#SetComponent doesn't seem to accept the parameters that seem to match the information
1 messages · Page 1 of 1 (latest)
you can't use Aspects like that, SetComponent and the other functions like that only take in IComponentData (or ICleanupComponentData)
if you are wanting to set the position do
new LocalTransform()
{
Value = new float3(i, i, i)
}
Oh my god, thank you, I've been trying different things for an hour now and I could not figure it out