ComponentsΒΆ
public struct ASAgent : IComponentData //Basic Agent
{
public float MaxSpeed; //Speed of agent when moving
public float Radius; //Radius of Agent
public float Height; //Height of Agent
public float TurnSpeed; //Turn speed when moving
public float NextTargetTouchDistance; //When moving from point to point in the path, this is the min distance that the agent will find enough to consider point reached (best value tends to be Grid.NodeSize but can vary, setting this value to a negative value will automatically use Grid.NodeSize)
public bool IgnoreAvoidanceWhenDestReached; //Stop being condidered as an avoidance agent if destination is reached, even if ASAvoidanceAgent is still attached.
public float StoppingDistance; //Distance from target point to consider it reached
public float3 CurrentVelocity; //Current Agent Velocity
}
public struct ASPathFollower : IComponentData //Path following data
{
public bool PathAvailable; //Is path available ?
public int TargetIndex; //Point index in ASPathBufferComponent that is being persued
public bool DestinationReached; //Is destination reached ?
}
public struct ASPathfindingRequester : IComponentData //Requests paths from the pathfindind system
{
public float3 Destination; //Destination point
public bool RequestGiven; //Is path given to the requester system ? Set this to false to request new path
public Entity RequestEntity; //Request entity being managed by the pathfindider (don't set this, it will be set by the requester system)
}
public struct ASConstantTargetFollower : IComponentData //Attach this for contant following of a target entity
{
public Entity Target; //Target entity to be followed (!!! Has to have a LocalTransform)
public bool RecalculateOnStationary; //Recalucate even if target does not move (Not recommended to set this to true, unless environment is changing constantly)
public float3 TargetLastPosition; //This position keeps track to know whether or not the target moved
}
public struct ASAvoidanceAgent : IComponentData //Avoidance agent, attach this to agent or it will be ignored by avoidance
{
public float TimeHorizon; //How far in the future to predict collision (standard value is 2)
}
[InternalBufferCapacity(0)] //Store all agents in heap
public struct ASAgentNeighboursBufferComponent : IBufferElementData //The neighbours that will be taken into account by avoidance, must be attached to agent along an ASAvoidanceAgent, but not set as it will be set automatically
{
public Entity Agent; //Neighbour Agent
}
public struct ASPathfindingOperation : IComponentData //A pathfinding operation, created by path requester
{
public float3 StartPoint; //Starting point
public float3 TargetPoint; //End point
}
[InternalBufferCapacity(0)] //Store points in heap
public struct ASPathBufferComponent : IBufferElementData //Pathpoints for the agent to follow
{
public float3 Point; //Point for agent to go to
}
public struct ASPathfindingResult : IComponentData //Result from pathfinding operation
{
public bool PathFound; //Was path found ?
public bool FinishedSearch; // Was operation complete ?
}
[InternalBufferCapacity(0)] //Store operations in heap
public struct ASPathfindingOperationsBuffer : IBufferElementData //the queue buffer that stores the pathfinding operations
{
public Entity RequestingAgentEntity; //Agent that is sending the request
public ASPathfindingOperation Operation; //The operation
}
public struct ASGrid : IComponentData //Grid
{
public float Width, Height; //Total width and height of grid
public int NodeXCount, NodeYCount; //Width/NodeSize and Height/NodeSize
public int InaccessibleLMIndex; //LayerMask value of Inaccessible nodes
public int PenaltyLMIndex; //LayerMask value of Penalty nodes
public float NodeSize; //Size of grid node
public DifferentIslandsPolicy DifferentIslandsPolicy; //The grid will be seperated into islands, each island being an area closed off by inaccessible nodes
//What to do when an agent requests a path on different islands
//Don't Path : Does not compute the path at all
//Go to closest : Goes to the closest no on the agents island (WARNING: this is not recommended
//if you have many agents and a dense grid )
public int TargetInaccessibleSearchTolerance; //if target is an inaccessible node, how far to to look for an accessible node in a radial direction (best between 10-20 increasing with grid density)
public int AvoidanceNeighbours; //Max Number of avoidance neighbour agents per agent, (best between 4 and 10)
public bool RecalcPathsAfterGridRefresh; //Reclculate paths for agents after grid refresh ?
public bool RefreshGrid; //Set it to true after adding or moving a new obstacle/penalty to reset nodes
public bool RefreshIslands; //Automatically set to true (after grid refresh) to refresh islands
}
public struct ASNodeIslandIDBufferComponent : IBufferElementData //2D flattened array of nodes, contains the ids of each node
{
public int IslandID;
}
public struct ASPathfindingParameters : IComponentData //Additional PathfindingParameters
{
public int MaxPathfindingOpsPerFrame; //Max number of pathfinding operations to calculate per frame
}
[InternalBufferCapacity(0)]
public struct ASGridNodesBufferComponent : IBufferElementData //2D flattened array of nodes
{
public ASNode Node; //Node in grid
}
public struct ASNode : IEquatable<ASNode>, IHeapItem<ASNode> //Node
{
public bool IsAccessible; //Is node accessible/walkable ?
public int X, Y; //X and Y coords of Node
public int GCost; //G cost for A* algo
public int HCost; //H cost for A* algo
public int Penalty; //Penalty on node, makes it less appealing to walk on
public int HeapIndex; //Min heap index
public int PreviousNodeIndex; //Used to retrace path when pathfinding system finds target point
}
public struct ASObstacle : IComponentData //Obstacle, must be attached on a collider with set layer mask
{
public int PenaltyOnObstacleValue; //An obstacle can have a penalty to make walking near it's edges less appealing for agents
}
public struct ASPenalty : IComponentData //Path penalty, must be attached on a collider with set layer mask
{
public int PenaltyValue; //A penalty makes walking on the nodes less appealing, useful for creating paths etc...
}