Search Unity

Different area costs depending on wall health

Discussion in 'Navigation' started by Repeperilka, Jan 15, 2020.

  1. Repeperilka

    Repeperilka

    Joined:
    Dec 22, 2016
    Posts:
    5
    Hello fellow Unity users!

    So I'm trying to make a tower defense game with base building. Everything you build in the area should be destructible, including walls. What I've done so far is making every wall set an area cost bellow them, and then the enemy AI will raycast every corner of the path to you to see if there is a wall in between you and the monster and, if so, attack the wall.

    The problem comes when the player moves because if the enemy was doing damage to a specific wall, it will build another path that will lead to a closer wall that may be full hp, thus taking more time to reach the player than if it would have keep attaking the first wall.

    So I was hoping that there were a way to tie each wall hp to the cost of their area. If not, well... I'm open to sugestions

    Thank you very much!
    (And my english is not very good, if you didn't understand something because of it, dont be afraid to ask)

    Edit: I also though of placing NavMeshLinks bellow the walls and setting the area cost modifier to their hp, but the enemies will keep using the link even though I unchecked that option in their agent. So if there is a way to make them not use the link but still take them into account when building the path, I'd say that will also work
     
    Last edited: Jan 15, 2020