Skip to content

Game.Prefabs.HumanData

Assembly:
Unknown (defined in project/game assembly)

Namespace: Game.Prefabs

Type: struct

Base: Implements Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter

Summary:
HumanData is a simple DOTS component that stores per-entity movement parameters for humanoid agents (walk speed, run speed and acceleration). It is a blittable value type intended to be attached to entities and used in ECS systems and jobs to drive movement logic.


Fields

  • public float m_WalkSpeed
    Speed used for walking. Typical units are Unity units (meters) per second. Default (when not explicitly set) is 0. Use this to control normal/grounded traversal speed.

  • public float m_RunSpeed
    Speed used for running/sprinting. Also in units per second. Should be >= m_WalkSpeed for sensible behavior.

  • public float m_Acceleration
    Acceleration applied when changing speed, in units per second squared. Controls how quickly the entity reaches target speeds.

Properties

  • (none)

Constructors

  • public HumanData()
    Default value-initialized struct constructor. All float fields default to 0 if not set explicitly. You can create an initialized instance using object initializer syntax: new HumanData { m_WalkSpeed = 1.5f, m_RunSpeed = 4f, m_Acceleration = 2f }

Methods

  • (none)

Usage Example

// Create an entity with HumanData and set movement parameters
var manager = World.DefaultGameObjectInjectionWorld.EntityManager;
var archetype = manager.CreateArchetype(typeof(HumanData));
var entity = manager.CreateEntity(archetype);

manager.SetComponentData(entity, new HumanData {
    m_WalkSpeed = 1.4f,      // meters/sec (typical human walk ~1.3-1.6 m/s)
    m_RunSpeed = 4.5f,       // meters/sec
    m_Acceleration = 3.0f    // m/s^2
});

// Using in a System (Entities.ForEach)
public partial class HumanMovementSystem : SystemBase
{
    protected override void OnUpdate()
    {
        float dt = Time.DeltaTime;

        Entities.ForEach((ref HumanData human, ref Translation pos, in SomeMovementTarget target) =>
        {
            // Example: simple speed application (illustrative only)
            float desiredSpeed = /* decide walk or run */ human.m_WalkSpeed;
            // compute movement using desiredSpeed and human.m_Acceleration...
        }).ScheduleParallel();
    }
}

Notes and recommendations: - As a plain IComponentData struct, HumanData is safe to use in jobs and scheduled systems. Fields are public and mutable; if multiple threads write the same component on the same entity, use appropriate synchronization patterns (or use parallel-safe patterns like chunk components). - Units are assumed to be Unity units (meters) per second; adapt values to your game's scale. - Because the struct has no explicit constructors or validation, ensure speeds/acceleration are set to sensible, non-negative values before use.