Search Unity

AI Mesh Agent jumps to other platform after instantiate.

Discussion in 'Navigation' started by Elian_Adrian, Dec 5, 2021.

  1. Elian_Adrian

    Elian_Adrian

    Joined:
    Feb 22, 2018
    Posts:
    11
    Hi All,

    I'm having a really strange issue/ bug that i can't figure out
    I am trying to spawn some enemies (containing NavMesh Agent script) on the B platform at the red star sign with the main character target and AI destination also on the B platform.
    Immediately after being spawned the AI jump to the A platform to the circle sign and they aren't able to reach the B platform.

    If i try to spawn the AI anywhere on the A platform and the AI destination is also on the A platform everything works fine and i have no issues.

    If i join the two platforms, and try to spawn the AI on the B platform, i don't have an issue, they spawn correctly at the asterisk sign

    The only issue is when i have the setup below and i don't know why.

    Can you please help me ?

    I spawn the using the code below :

    Code (CSharp):
    1. int r = rnd.Next(groupOfEnemies.Count);
    2. var enemy = Instantiate(groupOfEnemies[r]);
    3.                 enemy.transform.position = gameObject.transform.position;




    upload_2021-12-5_23-23-47.png
     
  2. Elian_Adrian

    Elian_Adrian

    Joined:
    Feb 22, 2018
    Posts:
    11
    As an update, while the game is running, if i try to select the AI and drag in the Editor the over to surface B, i can't pass the edge of platform A. I can move the AI backwards towards the platform A center, but not passed it's edge.
    Additionally, if i take a prefab and place it on platform B before starting the game the AI will behave normal. This issue only occurs with instantiated enemy AI Prefabs.
     
  3. Daahrien

    Daahrien

    Joined:
    Dec 5, 2016
    Posts:
    100
    Elian_Adrian likes this.