Skip to content

Game.Pathfind.PathTargetMoved

Assembly:
Namespace: Game.Pathfind

Type: struct

Base: System.ValueType

Summary:
Represents a simple component that records that a pathfinding target entity has moved. Contains the target Entity and the previous and new positions (float3). This struct implements IComponentData so it can be attached to entities, and IQueryTypeParameter so it can be used in query/type-parameter contexts in ECS systems.


Fields

  • public Entity m_Target
    Holds the Entity that moved (the path target). Use this to identify which in-game object/entity changed position.

  • public float3 m_OldLocation
    The previous location of the target before the move. Coordinates are in world space using Unity.Mathematics.float3.

  • public float3 m_NewLocation
    The new location of the target after the move. Coordinates are in world space using Unity.Mathematics.float3.

Properties

  • This type defines no properties. It exposes plain public fields suitable for lightweight, blittable component data.

Constructors

  • public PathTargetMoved(Entity target, float3 oldLocation, float3 newLocation)
    Initializes a new PathTargetMoved component with the specified target entity and its old and new positions.

Methods

  • This type defines no methods. It's a plain data container (IComponentData).

Usage Example

// Create and add the component to an event/notification entity
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity eventEntity = entityManager.CreateEntity();

// Example values
Entity movedTarget = someTargetEntity;
float3 oldPos = new float3(10f, 0f, 20f);
float3 newPos = new float3(12f, 0f, 22f);

// Add the PathTargetMoved component to the event entity
entityManager.AddComponentData(eventEntity, new Game.Pathfind.PathTargetMoved(movedTarget, oldPos, newPos));

// In a system you can query for PathTargetMoved to react to moved targets
Entities.ForEach((ref Game.Pathfind.PathTargetMoved moved) =>
{
    // handle moved.m_Target, moved.m_OldLocation, moved.m_NewLocation
}).WithoutBurst().Run();

{{ Notes: - Use this component as a lightweight event marker or payload to notify systems that a pathfinding target entity has changed position. - Because it is a blittable struct with public fields, it is efficient for use in ECS jobified systems and for passing via EntityManager operations. }}