#Unity ECS and Pathing

1 messages · Page 1 of 1 (latest)

frigid comet
#

I have created a simplistic A* pathing algorithm and agents for the DOTS system. However, I am getting random errors of which I believe are related to my node locking system to stop agents running over each other. Does anyone know what is going on? I've tried debugging it for a few hours now.

#

Here are my files:

#

MovementAuthoring ```c#
using UnityEngine;
using Unity.Entities;
using Unity.Collections;
using Pathfinding;
using Unity.Mathematics;

public struct PathPoint : IBufferElementData
{
public int2 position;
}

public struct MovementComponent : IComponentData
{
public float speed;
public bool isMoving;
public int currentPathIndex;
public int2 goal;

public bool hasRecalculatedPath;

public void SetPath(Path path)
{
    isMoving = true;
    currentPathIndex = 0;
    goal = path.endNode.position;
    hasRecalculatedPath = false;
}

}

public class MovementAuthoring : MonoBehaviour
{
public float speed;

private class Baker : Baker<MovementAuthoring>
{
    public override void Bake(MovementAuthoring authoring)
    {
        var entity = GetEntity(authoring, TransformUsageFlags.Dynamic);
        AddComponent(entity, new MovementComponent { speed = authoring.speed });
        AddBuffer<PathPoint>(entity);
    }
}

}