Search Unity

Raycasting Nav Points on a Sphere for NPC A.I

Discussion in 'Navigation' started by Vampyr_Engel, Mar 11, 2018.

  1. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    How do you cast Raycasts through the centre of a sphere or planet then cast it back through a nav point so that A.I or NPC characters can use this to move about on a sphere to say attack a base or patrol the front of a base or attack or capture a certain base or object does anyone know how to to do this please or have working example code please? Thanks hopefully in anticipation
     
  2. christougher

    christougher

    Joined:
    Mar 6, 2015
    Posts:
    558
    try this...
    http://forum.arongranberg.com/t/navmesh-on-a-spherical-planet/4108



    and I found this is a while ago, which is actually the approach you described...
    http://skeledurr.net/post/120149790225/bone-crush-spherical-grid-and-a-star-pathfinding

    and I've also played around with having multiple Unity Navmeshes overlapping on a Planet, stitched together with a ton of navmesh links, which didn't work too bad. You just need to have to have separate game objects with varying rotations with the navmesh component on them as it uses the gameobjects "up" to bake the navmesh surface...

    an example video I did of this:
     
    Last edited: Mar 26, 2018
  3. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    Sorry bit late but thanks
     
  4. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    The thing is do I have to change code in the Navmesh?
     
  5. christougher

    christougher

    Joined:
    Mar 6, 2015
    Posts:
    558
    I don't really understand your question...
     
  6. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    Raphael_Ninpo
    Jul '17
    Hi, I did some research in the source code and may have found how to get a navmesh on the whole sphere:

    [Album] Imgur 15


    I just removed these lines from NavmeshBase.cs, line 885:

    // Make sure the triangle is clockwise in graph space (it may not be in world space since the graphs can be rotated)
    if (!VectorMath.IsClockwiseXZ(node.GetVertexInGraphSpace(0), node.GetVertexInGraphSpace(1), node.GetVertexInGraphSpace(2))) {
    int tmp = node.v0;
    node.v0 = node.v2;
    node.v2 = tmp;
    }
     
  7. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    Thats what I mean I hope not
     
  8. christougher

    christougher

    Joined:
    Mar 6, 2015
    Posts:
    558
    Its so much better then even then, Aron released a spherical pathfinding beta available for download which dramatically improves the avoidance performance. Check it out on his downloads page...
     
  9. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    OK give me the link please and thanks
     
  10. christougher

    christougher

    Joined:
    Mar 6, 2015
    Posts:
    558
  11. Vampyr_Engel

    Vampyr_Engel

    Joined:
    Dec 17, 2014
    Posts:
    449
    OK thanks mate
     
  12. scradsleep

    scradsleep

    Joined:
    Nov 7, 2019
    Posts:
    21
    these post's are real old what is the situation with this these days? im trying to get a navmesh on sphercal LOD procedural
     
  13. christougher

    christougher

    Joined:
    Mar 6, 2015
    Posts:
    558
    https://forum.arongranberg.com/t/navmesh-on-a-spherical-planet/4108

    This is the A*PPP forum thread about the spherical beta. It's Pro version only and will run you $100 in the asset store but its by far the better solution than trying to patchwork nav meshes with unity's built in nav like my other posts. You can setup LOD's without too much hassle. The tail end of the thread is about obstacles. It's been a while since I messed with it but it has local avoidance with some DOTS/ECS optimizations as well.
     
  14. scradsleep

    scradsleep

    Joined:
    Nov 7, 2019
    Posts:
    21
    i did come across that thread in my search, cheers! i just wrote some a* with help of tutorials



    this little gem

    also using

    https://assetstore.unity.com/packages/tools/terrain/planetary-terrain-101118

    for the planet

    someone in PT discord mentioned setting up an a* per quad so im gonna see how and where i can fit them tomorrow hopefully we get a solution PT support is real good to so might be able to advise. if i can get that tutorial a* working ill see about spending the 100 on this optimized one...
    might be able to figure it out /shrugs will see.

    thanks anyway @christougher ill have a more indepth read of the thread at some point for sure.