static public int constructor(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif UnityEngine.AI.NavMeshHit o; o = new UnityEngine.AI.NavMeshHit(); pushValue(l, true); pushValue(l, o); return(2); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
static public int constructor(IntPtr l) { try { UnityEngine.AI.NavMeshHit o; o = new UnityEngine.AI.NavMeshHit(); pushValue(l, true); pushValue(l, o); return(2); } catch (Exception e) { return(error(l, e)); } }
public static Vector3 NavSamplePosition(Vector3 srcPosition) { Vector3 dstPosition = srcPosition; UnityEngine.AI.NavMeshHit meshHit = new UnityEngine.AI.NavMeshHit(); int layer = 1 << UnityEngine.AI.NavMesh.GetAreaFromName("Walkable"); if (UnityEngine.AI.NavMesh.SamplePosition(srcPosition, out meshHit, 100, layer)) { dstPosition = meshHit.position; } return(dstPosition); }
public static Vector3 RandomOnCircle(Vector3 center, float min, float max) { Vector3 randomPoint = UnityEngine.Random.insideUnitCircle * max; randomPoint += randomPoint.normalized; center += randomPoint; UnityEngine.AI.NavMeshHit meshHit = new UnityEngine.AI.NavMeshHit(); int layer = 1 << UnityEngine.AI.NavMesh.GetAreaFromName("Walkable"); if (UnityEngine.AI.NavMesh.SamplePosition(center, out meshHit, 100, layer)) { return(meshHit.position); } return(center); }
// Update is called once per frame void Update() { // Convert the mouse position to a ray and raycast to the terrain var mouseRay = cameraSource.ScreenPointToRay(Input.mousePosition); var hitInfo = new RaycastHit(); var terrainOnlyMask = 1 << 8; if (Physics.Raycast(mouseRay, out hitInfo, 1000, terrainOnlyMask)) { // If we are on the navmesh, we update our position var navHitInfo = new UnityEngine.AI.NavMeshHit(); if (UnityEngine.AI.NavMesh.SamplePosition(hitInfo.point, out navHitInfo, 5, UnityEngine.AI.NavMesh.AllAreas)) { reticle.position = navHitInfo.position; } } }
bool CanOpen() { if (open == 1.0f) { return(false); } // Is occupied? UnityEngine.AI.NavMeshHit hit = new UnityEngine.AI.NavMeshHit(); foreach (UnityEngine.AI.NavMeshAgent agent in agents) { agent.SamplePathPosition(-1, 0.0f, out hit); if ((hit.mask & 8) != 0) { return(false); } } return(true); }
public List <Vector3> RandomPointsInRoom() { List <Vector3> points = new List <Vector3>(); UnityEngine.AI.NavMeshHit[] hits = new UnityEngine.AI.NavMeshHit[units.Length]; SquadUnit unit; for (int i = 0; i < units.Length; i++) { unit = units[i]; Vector3 samplePos = unit.transform.position + new Vector3(Random.value * 4, 0, Random.value * 4); if (UnityEngine.AI.NavMesh.SamplePosition(samplePos, out hits[i], 4, 0)) { points.Add(hits[i].position); } } return(points); }
void Patrol() { if (target == null && m_NavAgent.isActiveAndEnabled && pathTime <= 0) { for (;;) { Vector3 randomDir = Random.insideUnitSphere * maxPatrolDistance; randomDir.y = Random.Range(0, 3.0f); randomDir += transform.position; UnityEngine.AI.NavMeshHit hit = new UnityEngine.AI.NavMeshHit(); if (UnityEngine.AI.NavMesh.SamplePosition(randomDir, out hit, maxPatrolDistance, UnityEngine.AI.NavMesh.AllAreas)) { storedPos = hit.position; m_NavAgent.SetDestination(storedPos); pathTime = CalculateDistance(transform.position, storedPos) / m_NavAgent.speed; break; } } } }
public static bool Raycast(Vector3 sourcePosition, Vector3 targetPosition, out NavMeshHit hit, NavMeshQueryFilter filter) { return(NavMesh.RaycastFilter(sourcePosition, targetPosition, out hit, filter.agentTypeID, filter.areaMask)); }
private static bool FindClosestEdgeFilter(Vector3 sourcePosition, out NavMeshHit hit, int type, int mask) { return(NavMesh.INTERNAL_CALL_FindClosestEdgeFilter(ref sourcePosition, out hit, type, mask)); }
private static extern bool INTERNAL_CALL_FindClosestEdgeFilter(ref Vector3 sourcePosition, out NavMeshHit hit, int type, int mask);
private static bool SamplePositionFilter(Vector3 sourcePosition, out NavMeshHit hit, float maxDistance, int type, int mask) { return(NavMesh.INTERNAL_CALL_SamplePositionFilter(ref sourcePosition, out hit, maxDistance, type, mask)); }
public static bool FindClosestEdge(Vector3 sourcePosition, out NavMeshHit hit, NavMeshQueryFilter filter) { return(NavMesh.FindClosestEdgeFilter(sourcePosition, out hit, filter.agentTypeID, filter.areaMask)); }
public static bool Raycast(Vector3 sourcePosition, Vector3 targetPosition, out NavMeshHit hit, int areaMask) { return(NavMesh.INTERNAL_CALL_Raycast(ref sourcePosition, ref targetPosition, out hit, areaMask)); }
public static bool SamplePosition(Vector3 sourcePosition, out NavMeshHit hit, float maxDistance, NavMeshQueryFilter filter) { return(NavMesh.SamplePositionFilter(sourcePosition, out hit, maxDistance, filter.agentTypeID, filter.areaMask)); }
// Locate the closest NavMesh edge from a point on the NavMesh. public static extern bool FindClosestEdge(Vector3 sourcePosition, out NavMeshHit hit, int areaMask);
public extern bool SamplePathPosition(int areaMask, float maxDistance, out NavMeshHit hit);
public static bool FindClosestEdge(Vector3 sourcePosition, out NavMeshHit hit, int areaMask) { return(NavMesh.INTERNAL_CALL_FindClosestEdge(ref sourcePosition, out hit, areaMask)); }
public static bool SamplePosition(Vector3 sourcePosition, out NavMeshHit hit, float maxDistance, int areaMask) { return(NavMesh.INTERNAL_CALL_SamplePosition(ref sourcePosition, out hit, maxDistance, areaMask)); }
private static bool RaycastFilter(Vector3 sourcePosition, Vector3 targetPosition, out NavMeshHit hit, int type, int mask) { return(NavMesh.INTERNAL_CALL_RaycastFilter(ref sourcePosition, ref targetPosition, out hit, type, mask)); }
// a CUSTOM "Raycast" exists elsewhere. We need to pick unique name here to compile generated code in batch-builds static extern bool RaycastFilter(Vector3 sourcePosition, Vector3 targetPosition, out NavMeshHit hit, int type, int mask);
// a CUSTOM "FindClosestEdge" exists elsewhere. We need to pick unique name here to compile generated code in batch-builds static extern bool FindClosestEdgeFilter(Vector3 sourcePosition, out NavMeshHit hit, int type, int mask);
// a CUSTOM "SamplePosition" exists elsewhere. We need to pick unique name here to compile generated code in batch-builds static extern bool SamplePositionFilter(Vector3 sourcePosition, out NavMeshHit hit, float maxDistance, int type, int mask);
// Sample the NavMesh closest to the point specified. public static extern bool SamplePosition(Vector3 sourcePosition, out NavMeshHit hit, float maxDistance, int areaMask);
private static extern bool INTERNAL_CALL_RaycastFilter(ref Vector3 sourcePosition, ref Vector3 targetPosition, out NavMeshHit hit, int type, int mask);
public extern bool FindClosestEdge(out NavMeshHit hit);
private static extern bool INTERNAL_CALL_FindClosestEdge(ref Vector3 sourcePosition, out NavMeshHit hit, int areaMask);
public bool Raycast(Vector3 targetPosition, out NavMeshHit hit) { return(NavMeshAgent.INTERNAL_CALL_Raycast(this, ref targetPosition, out hit)); }
private static extern bool INTERNAL_CALL_SamplePosition(ref Vector3 sourcePosition, out NavMeshHit hit, float maxDistance, int areaMask);
private static extern bool INTERNAL_CALL_Raycast(NavMeshAgent self, ref Vector3 targetPosition, out NavMeshHit hit);