Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

AI Navigation on a Spherical World

Discussion in 'Navigation' started by Cnc96, Jul 9, 2015.

  1. Cnc96

    Cnc96

    Joined:
    Dec 17, 2013
    Posts:
    57
    Hi all,
    I'm looking at creating a game where the player is on a spherical world like those in Super Mario Galaxy. I am wondering how I would go about having AI on this object?
     
  2. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    Hi, I'm not too familiar with the built-in pathfinding, but I doubt it supports more than regular platform navigation. You'll have to write an own solution that projects a navigation model onto your spherical object.
    This is rather easily done using waypoints as you can just place them like the vertices on an icosaeder style mesh. Connections between those would can be set up directly through the distance separating two waypoints.
    If you prefer a navigation map / texture overlay, a spherical surface can be a pain, as you need to deal with UV-mapping and texture stretching. Also there is the issue with looping the texture, which can be overcome with a set of if-else-variables.
    The characters' orientation can be determined using the local normal vector of the surface 'below' them.
    Hope that helped you :)
     
  3. TEBZ_22

    TEBZ_22

    Joined:
    Jan 28, 2014
    Posts:
    37
    Just a thought...
    Maybe map the spherical coordinates to a flat helper map (on a invisable layer or far far away) , going from , maybe, a dodecahedron ( or icosahedron ) to a map of pentagrams ( or triangles). Duplicate the obstacles and other "targets" on the flat map. To stitch together the naked edges, use Offmesh links.
    Make the navigation on the flat map, and map that back to the sphere.
    Quite a bit of math ...
     
  4. KlaRo115

    KlaRo115

    Joined:
    Feb 24, 2006
    Posts:
    675
    Well, first of all, it depends on how big and complex those planetoids would be.
    A very simple map on a tiny body doesn't really require complex navigation patterns and a basic waypoint approach could be implemented without a whole lot of effort. Also, as mentioned before, a dodecahedron or icosahedron overlay may be the easiest way to procedurally place the waypoints.
    Then again, a massive world with movement on several layers and realistic landscapes may just be easier to achieve using the spherical projection method Tebz_22 proposed.
    The main issue being reliability, you should think about what kind of goals you're setting for yourself and how those can be realized in the least complicated manner possible.
     
  5. Lahzar

    Lahzar

    Joined:
    May 6, 2013
    Posts:
    87
    Most pathfinding-solutions, I don't know about the builtin unity navmesh though, include a navmesh from mesh. So you could get one of those, slightly scale up the mesh, and use this as a navmesh. NavMesh is called navMESH for a reason, ya know.

    This is essentially what these other people, @KlaRo115 and @TEBZ_22, are talking about. Except you won't need to do much more work.