Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Navmesh Agent and Character Controller

Discussion in 'Navigation' started by alextoti33, Oct 3, 2019.

  1. alextoti33

    alextoti33

    Joined:
    Oct 8, 2017
    Posts:
    66
    Hello, so im using character controller for WASD movement, but i wanted to add navmesh agent in the game, so the player will be able to move with the mouse as well, while WASD works perfectly, navmesh agent, doesnt work (im using agent.destination = pos, tried setdestination and move as well, some times only rotates the player. I've tried disabling the character controller movement, but same problem.I'm using Unity 2018.3.7f1.
     
  2. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    491
    We'll need more information to help you here, but it does sound like the Agent and CharacterController are conflicting somehow even though your attempt at turning the Controller off seemed to not help.
    Show us what exactly you're doing.
     
  3. alextoti33

    alextoti33

    Joined:
    Oct 8, 2017
    Posts:
    66
    I'm trying to let players move with WASD and mouse in the same time
    The code: https://pastebin.com/xsDFS1uU
     
  4. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    491
    Yeah, even with that part commented out you're still using the Character Controller every frame, which overrides the Agent.
    Most people instead "hack" a solution where they only have a NavmeshAgent and use WASD to move the target position, as well as controlling it with mouse clicks.
     
  5. alextoti33

    alextoti33

    Joined:
    Oct 8, 2017
    Posts:
    66
    I see, thanks