Skip to content

NavMeshAgent.samplePosition

Wyatt Gillette edited this page Nov 2, 2021 · 2 revisions

Declaration

public boolean samplePosition(Vector3f center, float range, Vector3f result);

Parameters

center The origin of the sample query.
range Sample within this distance from center.
result Holds the resulting location.

Returns

boolean True if the nearest point is found.

Description

Finds the nearest point based on the NavMesh within a specified range.

float range = 4;
Vector3f point = new Vector3f();

NavMeshAgent agent;

if (agent.samplePosition(character.getWorldTranslation(), range, point)) {
    agent.setDestination(point);
}
Clone this wiki locally