Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IEnumerator Start() // Step one, beginning with caching data before going into the update loop
- {
- m_NavMesh = new NavMeshData();
- m_Instance = NavMesh.AddNavMeshData(m_NavMesh);
- if (m_Tracked == null)
- m_Tracked = transform;
- VoxelMapNavMeshSourceTag.Collect(ref m_Sources); //Populating the sources array and the array with moving objects helper class
- defaultBuildSettings = NavMesh.GetSettingsByID(0);
- bounds = QuantizedBounds();
- while (true)
- {
- UpdateNavMesh(true); //Pasted below
- yield return m_Operation;
- }
- }
- void UpdateNavMesh(bool asyncUpdate = false) //Update loop, first updating moving sources, followed by NavMesh rebuild
- {
- VoxelMapNavMeshSourceTag.UpdatePositions(m_Sources); //Iterates through the moving objects array, pasted below
- if (asyncUpdate)
- m_Operation = NavMeshBuilder.UpdateNavMeshDataAsync(m_NavMesh, defaultBuildSettings, m_Sources, bounds);
- else
- NavMeshBuilder.UpdateNavMeshData(m_NavMesh, defaultBuildSettings, m_Sources, bounds);
- }
- public static void UpdatePositions(List<NavMeshBuildSource> sourcesArray) //Content of the UpdatePositions method
- {
- for (var i = 0; i < sourcePositionUpdaters.Count; i++)
- {
- sourcesArray[sourcePositionUpdaters[i].index] = sourcePositionUpdaters[i].CloneSource(); // <- This works fine, creates new instance of the source and replaces the old one in the sources array at the same index
- //sourcePositionUpdaters[i].UpdatePosition();// <- This doesn't work (updating existing sources transform)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement