Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

To make an object float above other objects?

Discussion in 'Navigation' started by kittik, Jan 19, 2016.

  1. kittik

    kittik

    Joined:
    Mar 6, 2015
    Posts:
    565
    I am trying to make one object with a Nav Mesh Agent float above other objects with a Nav Mesh Agent.

    All objects are using the same Nav Mesh, however the floating one has a greater Base Offset. Although the object is floating, it will not float above other objects which have a lesser Base Offset.

    How could I best achieve the results I am looking for? Should this floating object use a separate Nav Mesh in the air, or is there a better solution?
     
  2. AndreiKubyshkin

    AndreiKubyshkin

    Joined:
    Nov 14, 2013
    Posts:
    213
    How about making only visual object float in the air but having nav agent actually moving on the ground?
     
  3. kittik

    kittik

    Joined:
    Mar 6, 2015
    Posts:
    565
    Thanks @AndreiKubyshkin, I haven't explained myself very well.

    One object is flying above the map, its nav mesh agent extends to the ground. As the agent is on the ground (along with moving ground objects), it is trying to move around the ground objects, not just flying above them. As the flying objects nav mesh uses the same floor as the slower ground objects, the flying objects nav mesh pushes the ground objects out of the way.

    My problem is trying to find a way to have the flying objects ignore the ground objects and just overtake them from above without pushing them.
     
    AndreiKubyshkin likes this.
  4. AndreiKubyshkin

    AndreiKubyshkin

    Joined:
    Nov 14, 2013
    Posts:
    213
    I can think of two solutions.

    First is to use separate layer (or floor) of navMesh, just as you said.

    Second is not use navMesh at all. For example in my game there're helicopters. They are flying above the trees and building and don't need any pathfinding to fly around. And to avoid collisions with higher obstacles like single mountains they're using raycasting.
     
    kittik likes this.
  5. kittik

    kittik

    Joined:
    Mar 6, 2015
    Posts:
    565
    Thank you @AndreiKubyshkin, I'll have my flying objects rely on raycasting objects in front of itself. That's been really helpful.
     
    AndreiKubyshkin likes this.