Ejemplo n.º 1
0
    private void LoadLevel()
    {
        Level level = levels[currentLevel];

        GameObject agent = CreateLevelElement(playerPrefab, level.Spawn, Quaternion.identity);

        _camera.SetAgent(agent);

        CreateLevelElement(finishPrefab, level.Finish, Quaternion.identity);

        foreach (Vector3 coords in level.Cubes)
        {
            GameObject       cube     = CreateLevelElement(cubePrefab, coords, Quaternion.identity);
            NavMeshSurface[] surfaces = cube.GetComponentsInChildren <NavMeshSurface>();
            foreach (NavMeshSurface surface in surfaces)
            {
                surface.BuildNavMesh();
            }
        }
    }