Game.RandomTransformData
Assembly:
Assembly-CSharp (typical game/mod assembly)
Namespace: Game.Prefabs
Type:
struct
Base:
Implements: Colossal.Mathematics.Bounds3-backed data; System interfaces: Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter
Summary:
RandomTransformData is a small ECS component that holds two Bounds3 ranges used to randomize the transform of a prefab or entity. m_PositionRange defines the allowed position offset (min/max for X/Y/Z) and m_AngleRange defines the allowed rotation range (min/max for X/Y/Z—typically used as Euler angles). This component is intended to be attached to entities to drive randomized placement/rotation when spawning or procedurally modifying prefabs.
Fields
-
public Bounds3 m_AngleRange
Range of rotation values (per-axis min/max). By convention this is used for Euler angle ranges (degrees), with the Bounds3 holding minimum and maximum float3 values. Use this to randomize an entity's orientation within the specified bounds. -
public Bounds3 m_PositionRange
Range of position offsets (per-axis min/max). The Bounds3 stores minimum and maximum float3 values that describe the allowable positional offset relative to the entity or prefab origin. Use this to produce randomized placement within the specified box.
Properties
- (none)
This struct contains only public fields; there are no properties.
Constructors
- (implicit)
public RandomTransformData()
Default, value-type constructor. All fields are zero-initialized (Bounds3 with zero min/max) if not explicitly set. Initialize fields manually or via an initializer to provide usable ranges.
Methods
- (none)
This struct does not declare methods. Any utility methods for sampling from Bounds3 are provided elsewhere (e.g., helper/random utilities) or can be implemented in systems that consume this component.
Usage Example
// Example: adding RandomTransformData to an entity with EntityManager
using Colossal.Mathematics;
using Unity.Entities;
using Unity.Mathematics;
// create an entity with an archetype that includes RandomTransformData
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
var archetype = entityManager.CreateArchetype(typeof(RandomTransformData));
var entity = entityManager.CreateEntity(archetype);
// set position range to a 1x1x1 box centered at origin (-0.5..0.5)
var posRange = new Bounds3
{
Min = new float3(-0.5f, -0.5f, -0.5f),
Max = new float3(0.5f, 0.5f, 0.5f)
};
// set angle range (degrees) for random yaw only
var angleRange = new Bounds3
{
Min = new float3(0f, 0f, 0f),
Max = new float3(0f, 360f, 0f) // rotate around Y (yaw)
};
entityManager.SetComponentData(entity, new RandomTransformData
{
m_PositionRange = posRange,
m_AngleRange = angleRange
});
Additional notes: - Bounds3 is from Colossal.Mathematics and typically exposes Min/Max float3 fields or properties — check the specific API in the game SDK for available members. - Because RandomTransformData implements IComponentData, it is a blittable value type suitable for use in jobs and ECS systems. - When sampling random values from the ranges, do so in deterministic contexts if reproducible placement is required, otherwise use suitable random number facilities in systems that process this component.