Search Unity

Agent vs Character Controller

Discussion in 'Navigation' started by mrCharli3, Dec 3, 2019.

  1. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    486
    If I have an animal that is wandering around, should I do that using the AI Agent, or should I do it using the Character controller? I keep seeing both used and not sure when to use what?
     
  2. vhman

    vhman

    Joined:
    Aug 13, 2018
    Posts:
    107
    If you need path finding - Agent. Agent have some build in movement, so it is not easy to override.
    Anyway, path can be found be NavMesh static class and moved by CharacterController.

    So - Agent moved by himself, CharacterController is moved by you.
    It depends on how much code you want to write.
     
  3. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    486
    Hmm, okay, so would you say that assets on the store that use Character controllers for AI are doing it wrong?
     
  4. vhman

    vhman

    Joined:
    Aug 13, 2018
    Posts:
    107
    No, they doesn't. You can use CaharacterController on top of NavMeshAgent, or any other AI.
    You can use Move() method form NavMeshAgent or CharacterController (both has it). Or use CharacterController to move NavMeshAgent.

     
    DwinTeimlon and mrCharli3 like this.