Search Unity

Player was stucked in body of AIs

Discussion in 'Navigation' started by pkhien95, Oct 31, 2015.

  1. pkhien95

    pkhien95

    Joined:
    Oct 10, 2015
    Posts:
    14
    I have modified the NavMeshAgent stopping distance to 5. When I disable the collider of Lion, Player can run through their body (picture below) and when I enable Collider, Player was pushed and "fly". How to solve this? Thank you. Sorry for my English.
     
    Last edited: Oct 31, 2015
  2. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    You can calculate the distance between the player and the lion center, than stop the lion navmesh agent when the distance is below a a certain value to be sure the lion will stop moving.
     
    pkhien95 likes this.
  3. pkhien95

    pkhien95

    Joined:
    Oct 10, 2015
    Posts:
    14
    Thank you. But when I move to attack the lion, my character's collider was pushed and he started "flying". And when I stopped the NavmeshAgent, the "Attack" animation (no root motion) of the lion make it translate forward a bit.
     
  4. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    Without seeing your character physics set up it is hard to figure out what is going on. Is your lion script adding some force to the player when it attacks ?
    You can trying chaing the character mass and see what happens, or simply force the character position to stay at it's last position (the position before he was attacking) and disable character physics.


    You can force the lion to stay at it's last position before attacking by code in the update function.
    Or you must correct the animation to make it root motion.