The project contains all 9 levels featured in the video https://youtu.be/6mNj3M1il_c
Unity DOTS (burst, jobs, ecs)
RenderMeshInstanced
DrawMeshInstancedIndirect
Data-Oriented Design
Avoiding extern calls
The project contains all 9 levels featured in the video https://youtu.be/6mNj3M1il_c
Unity DOTS (burst, jobs, ecs)
RenderMeshInstanced
DrawMeshInstancedIndirect
Data-Oriented Design
Avoiding extern calls
Replace existing code with the below, if you are getting error. AspectTransform is not found.
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
public readonly partial struct MoveToPositionAspect : IAspect
{
public readonly Entity Self;
readonly RefRW<LocalTransform> Transform;
private readonly RefRO<TargetPositionComponent> _targetPosition;
public float3 Position
{
get => Transform.ValueRO.Position;
set => Transform.ValueRW.Position = value;
}
public Unity.Mathematics.quaternion Rotation
{
get => Transform.ValueRO.Rotation;
set => Transform.ValueRW.Rotation = value;
}
public void Move(float time)
{
var (pos, rot) = CalculatePosBurst(Position,_targetPosition.ValueRO.Value.y, time);
Rotation = rot;
Position = pos;
}
//this is a hack. Copied extenstion code and put here
public (float3 pos, Unity.Mathematics.quaternion rot) CalculatePosBurst(float3 pos, float yOffset, float time)
{
var t = math.unlerp(yOffset, SceneTools.BURST_HEIGHT_SCALE + yOffset, pos.y);
pos.y = SceneTools.BURST_HEIGHT_SCALE * noise.cnoise(new float2(pos.x * SceneTools.NOISE_SCALE + time, pos.z * SceneTools.NOISE_SCALE + time)) +
yOffset * SceneTools.DEPTH_OFFSET;
var rot = math.nlerp(quaternion.identity, SceneTools.RotGoal, t);
return (pos, rot);
}}
using Unity.Burst;
using Unity.Collections;
using Unity.Entities;
using Unity.Transforms;
[BurstCompile]
[DisableAutoCreation]
public partial class PlayerSpawnerSystem : SystemBase
{
protected override void OnUpdate()
{
// This is bad code. Can somebody tell me how to instantiate entities at a position using a command buffer?
/*if (EntityManager.CreateEntityQuery(typeof(TargetPositionComponent)).CalculateEntityCount() != 0)
{
foreach (var (aspect, targetPos) in SystemAPI.Query<AspectTransform, TargetPositionComponent>())
{
aspect.Position = targetPos.Value;
}
Enabled = false;
return;
}*/
// Create a query to get entities with TargetPositionComponent
var targetPositionQuery = GetEntityQuery(typeof(TargetPositionComponent));
if (targetPositionQuery.CalculateEntityCount() != 0)
{
// Create a native array to hold entities with both components
using (var entities = targetPositionQuery.ToEntityArray(Allocator.TempJob))
{
// Iterate over each entity and set its position
Entities.WithAll<LocalTransform>().ForEach((Entity entity, ref LocalTransform translation, in TargetPositionComponent targetPos) =>
{
// Check if the entity has TargetPositionComponent
if (entities.Contains(entity))
{
// Set the position of the entity to the target position
translation.Position = targetPos.Value;
}
}).Run();
}
// Disable the system
Enabled = false;
}
var buffer = SystemAPI.GetSingleton<BeginSimulationEntityCommandBufferSystem.Singleton>().CreateCommandBuffer(World.Unmanaged);
var prefab = SystemAPI.GetSingleton<PlayerSpawnerComponent>().PlayerPrefab;
SceneTools.LoopPositions((i, p) =>
{
var entity = buffer.Instantiate(prefab);
buffer.SetComponent(entity, new TargetPositionComponent
{
Value = p
});
});
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.