Version: 2022.3
언어: 한국어

NavMesh.FindClosestEdge

매뉴얼로 전환
public static bool FindClosestEdge (Vector3 sourcePosition, out AI.NavMeshHit hit, int areaMask);

파라미터

sourcePosition The origin of the distance query.
hit Holds the properties of the resulting location.
areaMask A bitfield mask specifying which NavMesh areas can be passed when finding the nearest edge.

반환

bool True if the nearest edge is found.

설명

Locate the closest NavMesh edge from a point on the NavMesh.

The returned NavMeshHit object contains the position and details of the nearest point on the nearest edge of the navmesh. This can be used to query how much extra space there is around the agent.

// MeasureSpace
using UnityEngine;
using UnityEngine.AI;

public class MeasureSpace : MonoBehaviour { void DrawCircle(Vector3 center, float radius, Color color) { Vector3 prevPos = center + new Vector3(radius, 0, 0); for (int i = 0; i < 30; i++) { float angle = (float)(i + 1) / 30.0f * Mathf.PI * 2.0f; Vector3 newPos = center + new Vector3(Mathf.Cos(angle) * radius, 0, Mathf.Sin(angle) * radius); Debug.DrawLine(prevPos, newPos, color); prevPos = newPos; } }

void Update() { NavMeshHit hit; if (NavMesh.FindClosestEdge(transform.position, out hit, NavMesh.AllAreas)) { DrawCircle(transform.position, hit.distance, Color.red); Debug.DrawRay(hit.position, Vector3.up, Color.red); } } }

public static bool FindClosestEdge (Vector3 sourcePosition, out AI.NavMeshHit hit, AI.NavMeshQueryFilter filter);

파라미터

sourcePosition The origin of the distance query.
hit Holds the properties of the resulting location.
filter A filter specifying which NavMesh areas can be passed when finding the nearest edge.

반환

bool True if the nearest edge is found.

설명

Locate the closest NavMesh edge from a point on the NavMesh, subject to the constraints of the filter argument.

The returned NavMeshHit object contains the position and details of the nearest point on the nearest edge of the NavMesh. This can be used to query how much extra space there is around the agent.

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961