Ejemplo 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
 }
Ejemplo 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));
     }
 }
Ejemplo 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);
    }
Ejemplo 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);
    }
Ejemplo 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;
            }
        }
    }
Ejemplo 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);
 }
Ejemplo 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);
    }
Ejemplo 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;
             }
         }
     }
 }
Ejemplo 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));
 }
Ejemplo 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));
 }
Ejemplo n.º 11
0
 private static extern bool INTERNAL_CALL_FindClosestEdgeFilter(ref Vector3 sourcePosition, out NavMeshHit hit, int type, int mask);
Ejemplo 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));
 }
Ejemplo n.º 13
0
 public static bool FindClosestEdge(Vector3 sourcePosition, out NavMeshHit hit, NavMeshQueryFilter filter)
 {
     return(NavMesh.FindClosestEdgeFilter(sourcePosition, out hit, filter.agentTypeID, filter.areaMask));
 }
Ejemplo 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));
 }
Ejemplo 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));
 }
Ejemplo 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);
Ejemplo n.º 17
0
 public extern bool SamplePathPosition(int areaMask, float maxDistance, out NavMeshHit hit);
Ejemplo n.º 18
0
 public static bool FindClosestEdge(Vector3 sourcePosition, out NavMeshHit hit, int areaMask)
 {
     return(NavMesh.INTERNAL_CALL_FindClosestEdge(ref sourcePosition, out hit, areaMask));
 }
Ejemplo 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));
 }
Ejemplo 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));
 }
Ejemplo 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);
Ejemplo 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);
Ejemplo 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);
Ejemplo 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);
Ejemplo n.º 25
0
 private static extern bool INTERNAL_CALL_RaycastFilter(ref Vector3 sourcePosition, ref Vector3 targetPosition, out NavMeshHit hit, int type, int mask);
Ejemplo n.º 26
0
 public extern bool FindClosestEdge(out NavMeshHit hit);
Ejemplo n.º 27
0
 private static extern bool INTERNAL_CALL_FindClosestEdge(ref Vector3 sourcePosition, out NavMeshHit hit, int areaMask);
Ejemplo n.º 28
0
 public bool Raycast(Vector3 targetPosition, out NavMeshHit hit)
 {
     return(NavMeshAgent.INTERNAL_CALL_Raycast(this, ref targetPosition, out hit));
 }
Ejemplo n.º 29
0
 private static extern bool INTERNAL_CALL_SamplePosition(ref Vector3 sourcePosition, out NavMeshHit hit, float maxDistance, int areaMask);
Ejemplo n.º 30
0
 private static extern bool INTERNAL_CALL_Raycast(NavMeshAgent self, ref Vector3 targetPosition, out NavMeshHit hit);