Calculate NavMeshPath in C# gives 'Use of unassigned local variable'

Hi all,

What’s wrong with this C# code?

NavMeshPath navMeshPath;
navMeshAgent.CalculatePath(targetPos, navMeshPath);

I keep getting the ‘Use of unassigned local variable’ error.
What can I assign navMeshPath to?

Greets,

Tom

Fixed it, call the constructor first.

NavMeshPath navMeshPath = new NavMeshPath();
navMeshAgent.CalculatePath(targetPos, navMeshPath);