Need help with NPC movement (randomly walking around in top-down game)

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Hello

    Today I started working on NPCs for a top-down RPG and came up with a system that changes an NPC's direction and its state (moving/stopped) randomly every second. This worked nicely when there was only one NPC but when adding more, 2 things happened; It became easily apparent that the NPCs only move/change direction once a second, which isn't very aesthetic, and I started having issues aligning the correct NPC sprite with the correct NPC object and playing the correct animation.

    After being stuck at this for a while, my MFA was getting way too complicated and even crashing so I figured it's time to go to the forum for help. There's probably a way better solution I'm not seeing (or just a better way to do NPCs entirely).

    Attached is my MFA, stripped down to what I had before I started on getting it to work with multiple NPCs.
    Please login to see this attachment.

  • After creating this thread I continued with the other functions of NPCs, skipping the sprites and animations for now, and ran into an other issue: After adding events that reverse the movement of an NPC when walking into another NPC (to prevent them from overlapping, the same way I did it for Obstacles), NPCs for some reason do overlap a little bit and sometimes get stuck in each other. Gonna look into other ways of doing the movement, that'll probably solve my issues.

  • It appears that my issue stemmed from checking if an object is overlapping another instance of the same object. I was able to fix it by creating a mask for each NPC and checking if the NPC is overlapping the mask of an other NPC rather than the other NPC itself.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!