言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

NavMeshAgent.CalculatePath

Switch to Manual
public function CalculatePath(targetPosition: Vector3, path: NavMeshPath): bool;

Parameters

targetPosition リクエストされた目的地
path 計算結果のパス

Returns

bool パスが見つかった場合はtrue

Description

エージェントが目標値までにたどり着く道程を計算し、path引数に格納します

This function can be used to plan a path ahead of time to avoid a delay in gameplay when the path is needed. Another use is to check if a target position is reachable before moving the agent.

	var target: Transform;

	private var agent: NavMeshAgent;

	function Start () {
		agent = GetComponent.<NavMeshAgent>();
		var path: NavMeshPath;
		agent.CalculatePath(target.position, path);
		
		if (path.status == NavMeshPathStatus.PathPartial) {
			// The target cannot be reached...
		}
	}