News › Forums › RAIN › General Discussion and Troubleshooting › Destructable Voxel Terrain and Navmeshes
This topic contains 10 replies, has 4 voices, and was last updated by mqnguyen42 10 months, 3 weeks ago.
-
AuthorPosts
-
June 14, 2022 at 1:48 pm #27737
Hello,
I’ve recently started working with RAIN and have found it perfect for my needs. I am currently working on a tunneling game where the player must dig tunnels into the terrain while being chased by AI. Thus, I have decided to use a voxel plugin called Cubiquity. Creating a navmesh over the generated voxel terrain works surprisingly well.
However, the nature of my game requires frequent updating of the navmesh. This must be done everytime the player digs further into the terrain. In addition, regenerating the navmesh currently causes the game to pause until it finishes.
Is there a way for updating the navmesh to occur in the background? Is there a way to only update a section of the navmesh (For instance, where the player is digging)?
Also, feel free to suggest any further solutions.
This is my first time on the RAIN forum, so I apologize in advance for any mistakes I have made in this post.- This topic was modified 1 year ago by mqnguyen42.
- This topic was modified 1 year ago by mqnguyen42.
June 16, 2022 at 5:06 pm #27940I don’t know if there’s a way to force it into the background, but could multiple nav meshes work? If navmeshes overlap, AI can still traverse them.
What this means is that you just have to find which navmesh the player is currently in, and update only that. Since it’s a smaller section, it would no doubt update faster.
June 16, 2022 at 9:29 pm #27991Great idea.
However, the pausing to regen the navmesh will still be quite cumbersome.
If the RAIN team would consider dynamic navmesh updating, that would make RAIN more awesome than it already is.
June 16, 2022 at 9:30 pm #27992They are working on dynamic object avoidance, which Primer has stated this will update navmesh at real time. You may want to wait on that, then, unfortunately.
June 16, 2022 at 9:49 pm #27996Any idea when that will be released?
June 16, 2022 at 10:05 pm #27998Contact the RT team to see when the next release comes out.
Note, until then… you can do simple avoidance through raycasting. If something is detected get the angle offset position and assign that as your new move target. You may have to disable “Valid Path Required” in the AIRing motion panel and also reset path finding search ai.Navigator.RestartPathfindingSearch(). This should allow the ai to break from current path target and go to the one you defined. Once the target has been avoided (the raycast is not hitting) re-enable “Valid Path Required”.
- This reply was modified 1 year ago by CodersExpo.
June 16, 2022 at 10:30 pm #28002One last thing-Is there a way to regenerate the navmesh from script? (Not by clicking “Generate Navigation Mesh” in the editor)
June 16, 2022 at 10:38 pm #28003I don’t believe there is an easy way to dynamically create navigation meshes. This is something the RT team is working on but I’m not sure when we’ll see this. It’s a good question to contact them about.
In the mean time you might try messing around with this. Basically, if you have a navigation mesh rig and you have defined the properties there, you can essentially “click” the generate mesh graph in code like this.
RAIN.Navigation.NavMesh.NavMeshRig rig = GameObject.FindGameObjectWithTag(“NavMesh”).GetComponent<RAIN.Navigation.NavMesh.NavMeshRig>();
RAIN.Navigation.NavMesh.NavMesh mesh = rig.NavMesh;
//clear the existing navmesh
mesh.UnregisterNavigationGraph();
mesh.StartCreatingContours(rig, 1);
while(mesh.Creating)
{
mesh.CreateContours();
System.Threading.Thread.Sleep(10);
}
mesh.GenerateAllContourVisuals();
mesh.RegisterNavigationGraph();June 16, 2022 at 10:45 pm #28004Thanks, that’s exactly what I needed. Also, dynamic obstacle avoidance is not really what I’m looking at, I need deformation of the navmesh in accordance to deformation of voxel terrain. I guess I’ll have to deal with that minuscule pause that comes with navmesh generation. That’s why I’m looking at solutions to regen the navmesh as a background process.
August 15, 2022 at 12:51 am #32849This is theorycrafted so take it with some salt… You could have 2 navmesh objects and switch between which one is active (by turning it on/off in the heirarchy) and then update the other one in a subroutine thread, and then switch when done. It would mean that pathfinding wouldn’t work perfectly until the subroutine is done but I think that’s to be expected.
August 15, 2022 at 1:16 am #32851Thanks for responding!
A few months ago, I was almost able to solve my problem with multiple navmeshes as you suggested. However, the real issue turned out to be threading in Unity.
Apparently Unity does not support multithreading currently.
If you have any information on a workaround threading solution, please let me know.
-
AuthorPosts
You must be logged in to reply to this topic.