Search Unity

NavMesh Agent sliding and skating around

Discussion in 'Navigation' started by LDenckert, Dec 3, 2021.

  1. LDenckert

    LDenckert

    Joined:
    May 25, 2013
    Posts:
    1
    Hi there,
    I only recently started with Unity and I followed the old Brackeys Tutorial on Navmesh agents and movement.
    Now I am encountering a problem.

    I have attached a link to a video showing the behavior.

    at first it looks like the player character behaves correctly, but the more it walks around,it starts to "slide" and skate along the surface, totally "forgetting" about directions, rotating towards the target destination etc.
    what could cause this ? how do I fix this ?

    thanks in advance.

    (oh and adjusting the Angular Speed on the navmesh agent does not change anything in regards to this behavior. )

    here´s the playercontroller script, -> target selection

    and the player Motor script which does the actual moving

    I would really appreciate some help with this. it feels like I am pretty much stuck right now. thanks in advance
     
  2. way3edgy

    way3edgy

    Joined:
    Feb 6, 2014
    Posts:
    30
    I think your Navmesh agent's rotation is conflicting with your FaceTarget() method. It wants to face the direction it's moving in and your method is re-aligning it to face the final destination.

    Edit: Correct me if I'm wrong but it looks like you tried to make it stop updating rotation on the nav agent when it's within a certain radius of the target and that might be where it's conflicting in that brief window between reaching the target and when it's slipping in and out of the radius.
     
    Last edited: Dec 6, 2021