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

スクリプト言語

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

NavMesh.CalculatePath

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public static function CalculatePath(sourcePosition: Vector3, targetPosition: Vector3, passableMask: int, path: NavMeshPath): bool;
public static bool CalculatePath(Vector3 sourcePosition, Vector3 targetPosition, int passableMask, NavMeshPath path);
public static def CalculatePath(sourcePosition as Vector3, targetPosition as Vector3, passableMask as int, path as NavMeshPath) as bool

Parameters

sourcePosition リクエストした初期位置
targetPosition リクエストした目的地
passableMask パスの計算時に特定のマスクをかけるためにナビメッシュレイヤーを渡すことが出来る
path 計算結果のパス

Returns

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

Description

2点間の位置を計算して、ナビメッシュオブジェクト上で移動できる範囲のパスを作成します

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 mesh: NavMesh;
	var target: Transform;

	private var path: NavMeshPath;

	function Start () {
		mesh.CalculatePath(transform.position, target.position, -1, path);
	}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public NavMesh mesh;
    public Transform target;
    private NavMeshPath path;
    void Start() {
        mesh.CalculatePath(transform.position, target.position, -1, path);
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	public mesh as NavMesh

	public target as Transform

	private path as NavMeshPath

	def Start() as void:
		mesh.CalculatePath(transform.position, target.position, -1, path)