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

スクリプト言語

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

NavMesh.FindClosestEdge

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 FindClosestEdge(sourcePosition: Vector3, hit: NavMeshHit, passableMask: int): bool;
public static bool FindClosestEdge(Vector3 sourcePosition, NavMeshHit hit, int passableMask);
public static def FindClosestEdge(sourcePosition as Vector3, hit as NavMeshHit, passableMask as int) as bool

Parameters

sourcePosition クエリとなる距離の原点
hit 一番近い辺のヒット情報
passableMask 最も近い辺を求める時に特定のマスクをかけるためにナビメッシュレイヤーを渡すことが出来る

Returns

bool 最も近い辺が見つかった場合はtrue

Description

特定の位置から最も近いナビメッシュオブジェクトの辺の情報を取得します

The returned NavMeshHit object contains the position and details of the nearest point on the nearest edge of the navmesh. Since an edge typically corresponds to a wall or other large object, this could be used to make a character take cover as close to the wall as possible.

	var mesh: NavMesh;
	var player: Transform;

	// Move a marker object to show a position of cover
	// that the player should head for.
	function IndicateCoverPosition() {
		var hit: NavMeshHit;
		
		if (mesh.FindClosestEdge(player.position, hit, -1)) {
			transform.position = hit.position;
		}
	}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public NavMesh mesh;
    public Transform player;
    void IndicateCoverPosition() {
        NavMeshHit hit;
        if (mesh.FindClosestEdge(player.position, out hit, -1))
            transform.position = hit.position;
        
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	public mesh as NavMesh

	public player as Transform

	def IndicateCoverPosition() as void:
		hit as NavMeshHit
		if mesh.FindClosestEdge(player.position, , -1):
			transform.position = hit.position