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. Dismiss Notice

NavMesh agent Pathfinding Zombies

Discussion in 'Navigation' started by Chinot, Mar 23, 2015.

  1. Chinot

    Chinot

    Joined:
    Mar 23, 2015
    Posts:
    1


    What i want to do is similiar what in Call of Duty Nazi zombies mode

    Player is in house, zombies are going to eat the player but if there is door in zombie's path/way then he have to break that door first and then continue to the player.

    I was thinking something like this

    Zombie is scanning all doors including empty door holes, then chooses the one what is closest to him and goes that way EVEN if there is empty door hole like 5m longer distance but it always chooses the closest want, thats what i want for that part, but i dont know how i can make this work properly.

    I tried to add collider box to doors and stop zombies and i somehow got it work but its not quite right i guess because zombies are still coming a bit through the doors and if player is next to that door zombies start hurting the player because i use simple check like this

    if(Distance < 2.0f) { ZombieAttackPlayer(); }

    I need some help how i can do this system properly, please and thanks!
     
  2. AgentParsec

    AgentParsec

    Joined:
    May 5, 2012
    Posts:
    403
    My suggestion would be to have the zombies stop when they're within a certain distance of the door, and then go into some state where they're clawing at the door. During this state, they damage the door and won't damage the player. That's a start anyway, although it won't take into account things like the player running outside through another door.
     
  3. jpthek9

    jpthek9

    Joined:
    Nov 28, 2013
    Posts:
    944
    AgentParsec got it generally right but you'll have to check which side of the door the zombie's on and cull the checks for less overhead. You could also do collision/trigger checks which will take a lot of the code off your shoulders