wave4-unity-mathematics-random-per-entity

Generates deterministic per-entity random streams for parallel ECS jobs.

6|Updated Apr 2, 2026
One-click install
npx skills add https://github.com/dyCuong03/unity-agent-team --skill wave4-unity-mathematics-random-per-entity
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: wave4-unity-mathematics-random-per-entity
Source: https://github.com/dyCuong03/unity-agent-team/tree/main/.claude/skills/unity-dots/wave4-unity-mathematics-random-per-entity
Command: npx skills add https://github.com/dyCuong03/unity-agent-team --skill wave4-unity-mathematics-random-per-entity

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It solves the challenge of generating random values that are both deterministic and safely usable in parallel ECS jobs without introducing shared-state correlations.

Core Features & Use Cases

  • Per-entity deterministic randomness: Produces statistically independent streams by seeding via entity index using Unity.Mathematics.Random.CreateFromIndex().
  • Burst-safe parallel execution: Ensures each worker advances its own RNG derived for that entity, avoiding race conditions.
  • Two workflows: One-shot spawn variation (create RNG inside Execute) and persistent per-entity randomness (store Random as IComponentData and pass by ref).

Quick Start

Tell an AI to show how to create a Burst job that uses Unity.Mathematics.Random.CreateFromIndex((uint)entityIndex + FrameSeed) to generate deterministic per-entity offsets and scales in an IJobEntity Execute method.

Frequently Asked Questions about wave4-unity-mathematics-random-per-entity

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate deterministic random numbers per entity in Unity ECS parallel jobs?

To generate deterministic random numbers per entity in Unity ECS, use Unity.Mathematics.Random.CreateFromIndex((uint)entityIndex + FrameSeed) inside an IJobEntity Execute method to produce statistically independent streams across worker threads.

Why does Unity.Mathematics.Random cause race conditions in Burst jobs and how do I fix it?

Unity.Mathematics.Random causes race conditions in Burst jobs when multiple worker threads mutate a shared RNG instance. Fix it by seeding an independent RNG stream per entity index using Random.CreateFromIndex, ensuring zero shared mutable state across parallel execution.

How do I create per-entity spawn variation in an IJobEntity without allocating memory?

Create per-entity spawn variation in an IJobEntity without memory allocation by initializing a local Unity.Mathematics.Random variable inside the Execute method using Random.CreateFromIndex, satisfying zero-allocation and Burst-safe RNG requirements.

Can I store persistent random streams as IComponentData for reproducible randomness across frames?

Yes, you can store persistent random streams as IComponentData by saving the Random struct to a component and passing it by ref to the Execute method, ensuring per-entity state advances deterministically across frames without re-seeding.

What is the best way to seed independent random streams for parallel ECS entities?

The best way to seed independent random streams for parallel ECS entities is Random.CreateFromIndex with a seed derived from the entity index and frame seed, producing statistically independent, deterministic results safely across multiple worker threads.

Does this per-entity random number generation approach work with IJobChunk scenarios?

Yes, this deterministic per-entity random number generation approach works with both IJobEntity and IJobChunk scenarios, allowing reproducible random values by applying entity index-based seeding to generate independent streams within chunk-based parallel execution.