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

How to make certain object/character so that they cannot move on certain terrain. (SOLVED)

Discussion in 'Navigation' started by izzanfuad, Mar 11, 2022.

  1. izzanfuad

    izzanfuad

    Joined:
    Dec 7, 2021
    Posts:
    32
    Hi there! I'm pretty new in Unity and wanted to ask about the AI navigation for my RTS game. Is there a certain way so that certain characters/objects cannot move in certain terrain? For example ships cannot go in land, tank can cross river but not sea, etc.
    If you guys have any link to a tutorial video it will also be a great help!!
     
  2. soleron

    soleron

    Joined:
    Apr 21, 2013
    Posts:
    568
    There is no single answer that covers all cases as it depends on what you are trying to do.

    i.e. the simplest way is to mark certain areas as walkable while others as non-walkable or create blockers that only allow an object to move only up to that point, or separate objects by layers etc. There are many ways to approach this depending on the complexity you are trying to manage.

    I would recommend you start by following the tutorials about Navigation.

    https://learn.unity.com/tutorial/navigation-basics
     
  3. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    266
    For something like this I'd expect you'd have fairly complex NavMeshModifiers and NavMeshModifierVolumes to adjust the area types of each "land type" to make, for example Tanks generally prefer being on land, but will go through a river if needed (maybe they go slower through water). Mark seas as "Not Walkable" for tanks, land as "Not Walkable" for boats, etc.. This tutorial from the AI series may help.
     
  4. izzanfuad

    izzanfuad

    Joined:
    Dec 7, 2021
    Posts:
    32
    I finally did it thank you guys!!!
     
    soleron likes this.
  5. izzanfuad

    izzanfuad

    Joined:
    Dec 7, 2021
    Posts:
    32
    Did it! Thanks
     
    ChrisKurhan and soleron like this.