A* Pathfinding Project

Making RichAI sticky to Recast Graph? [4.3]


#1

hi,

how can i make RichAI sticky to Recast Graph? [4.3.x]

thanks.


#2

Hi

Sticky in what way?


#3

i want to stick ai on navmesh [Recast Graph] even has no gravity!


#4

You can do something like

RichAI ai;

NNConstraint nnConstraint = new NNConstraint {
    distanceXZ = true,
};

void Start () {
    ai = GetComponent<RichAI>();
}

void LateUpdate () {
    ai.position = AstarPath.active.GetNearest(ai.position, nnConstraint).position;
}

#5

thanks …
but seems that ai.position is readonly!!


#6

Ah. I mean

NNConstraint nnConstraint = new NNConstraint {
    distanceXZ = true,
};

void LateUpdate () {
    transform.position = AstarPath.active.GetNearest(transform.position, nnConstraint).position;
}