Forum rules - please read before posting.

NPC "Move to point" or "Move along path" not working

Hi - I'm having trouble to move my NPC. It's a 2D game and I'm new to AC. I used the Character Wizard to create the NPC, and added Default NavMesh (Polygon Collider) to the walkable area like shown in the 2D tutorial. If "Move to Point" the NPC would not move, if "Move along path" with teleport to start enabled it would teleport to start point and then stop moving. If "Wait until finish" is checked then it would just be stuck at that step, otherwise the step would be skipped. I've also tried toggling "Pathfind" in the ActionList and the Circle Collider 2D on the NPC--did not seem to make any difference.

What could the problem be? Thanks in advance.

Comments

  • Sorry forgot to mention I'm using AC 1.79.3 and Unity 2022.3.17

  • Welcome to the community, @atessa.

    We'll need to determine if this is an issue with your NPC, or with the scene's NavMesh.

    From what you describe, it sounds like its to do with the NPC. You can check this by dropping the 2D Demo's Player character, Brain2D, into your scene and amended your Actions to have them update him instead - is Brain able to move correctly?

    If so, check that NPC's Walk speed has a positive value, and that their Animator doesn't have Apply Root Motion checked, as this will cause the character to move purely through root-motion animation. If you can post screenshots of your character's full Inspector, I'll see if I can spot any issue.

    Otherwise, check your Console window - are any related messages appearing when attempting to move the NPC?

  • Thank you for the fast response!

    I did not import all the demo assets since I did the tutorial in a different project. But I tried with Barry the bird 2D NPC, and it moved as expected. So it is indeed probably the NPC.

    The walk speed is positive (default value) and the Apply Root Motion is unchecked. I don't think I noticed any messages that are different from when moving Barry. Here's the link to the screenshots of the inspector windows of my NPC and its sprite component (not sure how to attach them directly to the post). Please let me know if you spot any issue, thanks again!

    https://imgur.com/a/2Cm7bmW

  • Thanks for the details.

    It looks to be because the Motion control field is set to Manual, which is intended to allow integration with custom motion controllers. When this option is set, AC won't affect the character's motion directly - but public functions such as GetTargetPosition can still be read by a separate asset to work out where AC "wants" them to go based on the Actions.

    Setting this to the default Automatic value should cause them to move again - though I see you also have a custom "Pup Control" script attached. It's important to only have one component affect the character's position at a time - if this custom script also tries to move the NPC, at the same time as AC's Automatic mode, then you'll likely end up with a conflict with the two trying to move the NPC at the same time.

    Essentially: if you set to Automatic, also prevent any custom scripts from moving the character; if set to Manual, your custom scripts will be responsible for moving the character.

    More details on this topic can be found in the Manual's "Custom motion controllers" chapter, as well as this tutorial.

  • edited February 8

    Setting motion control to Automatic fixed the issue! You also answered another question that I was wondering (if both AC control and script control are trying to move the NPC, which of them takes the priority), it seems I better avoid doing that... I'll look into the linked tutorial as well.

    Thanks so much for your help!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.