Search Unity

Pathfinding with dynamic objects?

Discussion in 'Scripting' started by Tudvari, Dec 24, 2015.

  1. Tudvari

    Tudvari

    Joined:
    Jun 3, 2014
    Posts:
    30
    Hello guys!
    I have seen tutorials which shows that how can I make a Creature avoid the obstacles, calculate a path etc.
    But those tutorials didn't really showed how can I make a Creature avoid other moving creatures.

    So my question is this:
    Do I have to solve this problem on my own, or is it built in Unity? (or available in the asset store for free)

    Example for my problem:
    I command 10 melee soldiers to attack a rounded tower but instead of standing around the tower (so everyone can attack at the same time) 3 soldiers attack the tower, while the 7 others are just walking in place. (Because the others block the way for them)

    Thank you for your further help and sorry for my English! :)
     
  2. Tudvari

    Tudvari

    Joined:
    Jun 3, 2014
    Posts:
    30
    Now I am working with Unity's NavMeshAgent, but it didn't solve my problem with the local collosion avoidance.
    My code is this: if a creature starts attacking a tower (so he is in attack range), I disable the Agent, and enable the Obstacle so the others who are not yet attacking will avoid them, and they will select a new path to the tower.
    I paused the scene, and there were 3 creatures attacking, and they were obstacles. And there was 1 creature who wasn't attacking, and so he was agent. But for some reason he didn't look for a new path, instead he was "pushing" his ally like in the previous times.

    I got it finally. I check "Curved" at the Obstacle component.
     
    Last edited: Dec 24, 2015