Example #1
0
 public Triangle(int vertexIndex1, int vertexIndex2, int vertexIndex3, SphericalNavMesh father)
 {
     this.father      = father;
     vertexIndeces    = new int[3];
     vertexIndeces[0] = vertexIndex1;
     vertexIndeces[1] = vertexIndex2;
     vertexIndeces[2] = vertexIndex3;
     normal           = Vector3.Cross(GetVertex(1) - GetVertex(0), GetVertex(2) - GetVertex(0)).normalized;
     //collidingRadius = Vector3.Distance((GetVertex(1) + GetVertex(0)) / 2f, GetCenter());
 }
Example #2
0
    protected void OnCollisionStay(Collision other)
    {
        if (other.gameObject.CompareTag("Ground"))
        {
            currentPlanet = other.gameObject;
            navSurface    = currentPlanet.GetComponent <SphericalNavMesh>();

            if (updateNavigationPath && !isComputing() && navSurface.IsUpdatedCorrectly())
            {
                StartCoroutine(BeginAStar());
            }
        }
    }
Example #3
0
    protected void LateUpdate()
    {
        if (path == null || path.Count == 0)
        {
            return;
        }
        if (!alreadySimplified)
        {
            path = GetSimplifiedPath(path);
        }

        //only for debug
        List <Vector3> vertices = new List <Vector3>();

        path.ForEach(n =>
        {
            vertices.Add(n.vertex);
        });
        SphericalNavMesh.DebugPath(vertices.ToArray(), Color.cyan);
    }
Example #4
0
 public void Init()
 {
     navMesh = UnityEngine.GameObject.FindGameObjectWithTag("Ground").GetComponent <SphericalNavMesh>();
     navMesh.ComputeMeshData();
 }