Esempio n. 1
0
 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
 }
Esempio n. 2
0
 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));
     }
 }
Esempio n. 3
0
    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);
    }
Esempio n. 4
0
    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);
    }
Esempio n. 5
0
    // 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;
            }
        }
    }
Esempio n. 6
0
 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);
 }
Esempio n. 7
0
    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);
    }
Esempio n. 8
0
 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;
             }
         }
     }
 }
Esempio n. 9
0
 public static bool Raycast(Vector3 sourcePosition, Vector3 targetPosition, out NavMeshHit hit, NavMeshQueryFilter filter)
 {
     return(NavMesh.RaycastFilter(sourcePosition, targetPosition, out hit, filter.agentTypeID, filter.areaMask));
 }
Esempio n. 10
0
 private static bool FindClosestEdgeFilter(Vector3 sourcePosition, out NavMeshHit hit, int type, int mask)
 {
     return(NavMesh.INTERNAL_CALL_FindClosestEdgeFilter(ref sourcePosition, out hit, type, mask));
 }
Esempio n. 11
0
 private static extern bool INTERNAL_CALL_FindClosestEdgeFilter(ref Vector3 sourcePosition, out NavMeshHit hit, int type, int mask);
Esempio n. 12
0
 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));
 }
Esempio n. 13
0
 public static bool FindClosestEdge(Vector3 sourcePosition, out NavMeshHit hit, NavMeshQueryFilter filter)
 {
     return(NavMesh.FindClosestEdgeFilter(sourcePosition, out hit, filter.agentTypeID, filter.areaMask));
 }
Esempio n. 14
0
 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));
 }
Esempio n. 15
0
 public static bool SamplePosition(Vector3 sourcePosition, out NavMeshHit hit, float maxDistance, NavMeshQueryFilter filter)
 {
     return(NavMesh.SamplePositionFilter(sourcePosition, out hit, maxDistance, filter.agentTypeID, filter.areaMask));
 }
Esempio n. 16
0
 // Locate the closest NavMesh edge from a point on the NavMesh.
 public static extern bool FindClosestEdge(Vector3 sourcePosition, out NavMeshHit hit, int areaMask);
Esempio n. 17
0
 public extern bool SamplePathPosition(int areaMask, float maxDistance, out NavMeshHit hit);
Esempio n. 18
0
 public static bool FindClosestEdge(Vector3 sourcePosition, out NavMeshHit hit, int areaMask)
 {
     return(NavMesh.INTERNAL_CALL_FindClosestEdge(ref sourcePosition, out hit, areaMask));
 }
Esempio n. 19
0
 public static bool SamplePosition(Vector3 sourcePosition, out NavMeshHit hit, float maxDistance, int areaMask)
 {
     return(NavMesh.INTERNAL_CALL_SamplePosition(ref sourcePosition, out hit, maxDistance, areaMask));
 }
Esempio n. 20
0
 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));
 }
Esempio n. 21
0
 // 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);
Esempio n. 22
0
 // 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);
Esempio n. 23
0
 // 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);
Esempio n. 24
0
 // Sample the NavMesh closest to the point specified.
 public static extern bool SamplePosition(Vector3 sourcePosition, out NavMeshHit hit, float maxDistance, int areaMask);
Esempio n. 25
0
 private static extern bool INTERNAL_CALL_RaycastFilter(ref Vector3 sourcePosition, ref Vector3 targetPosition, out NavMeshHit hit, int type, int mask);
Esempio n. 26
0
 public extern bool FindClosestEdge(out NavMeshHit hit);
Esempio n. 27
0
 private static extern bool INTERNAL_CALL_FindClosestEdge(ref Vector3 sourcePosition, out NavMeshHit hit, int areaMask);
Esempio n. 28
0
 public bool Raycast(Vector3 targetPosition, out NavMeshHit hit)
 {
     return(NavMeshAgent.INTERNAL_CALL_Raycast(this, ref targetPosition, out hit));
 }
Esempio n. 29
0
 private static extern bool INTERNAL_CALL_SamplePosition(ref Vector3 sourcePosition, out NavMeshHit hit, float maxDistance, int areaMask);
Esempio n. 30
0
 private static extern bool INTERNAL_CALL_Raycast(NavMeshAgent self, ref Vector3 targetPosition, out NavMeshHit hit);