News Forums RAIN General Discussion and Troubleshooting Destructable Voxel Terrain and Navmeshes

Tagged: ,

This topic contains 10 replies, has 4 voices, and was last updated by  mqnguyen42 10 months, 3 weeks ago.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #27737

    mqnguyen42
    Participant

    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.
    #27940

    Vasir
    Participant

    I 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.

    #27991

    mqnguyen42
    Participant

    Great 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.

    #27992

    Vasir
    Participant

    They 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.

    #27996

    mqnguyen42
    Participant

    Any idea when that will be released?

    #27998

    CodersExpo
    Participant

    Contact 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.
    #28002

    mqnguyen42
    Participant

    One last thing-Is there a way to regenerate the navmesh from script? (Not by clicking “Generate Navigation Mesh” in the editor)

    #28003

    CodersExpo
    Participant

    I 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();

    #28004

    mqnguyen42
    Participant

    Thanks, 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.

    #32849

    RFDaemoniac
    Participant

    This 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.

    #32851

    mqnguyen42
    Participant

    Thanks 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.

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.