NPC movements

0 favourites
  • 3 posts
From the Asset Store
Fantasy RPG Human-NPC assets pack of 15 characters
  • Hello everyone,

    I am making a RPG and you all know how important NPCs are and NPC movement are also very important my problem is how I move NPC to a certain position and then come back to its original position and then go back to that certain position and this process go on forever but when player collides with NPC the NPC stops and after talking to player it continues its walking pattern.

    Please can anyone help.Thanks..

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Couple of ways, easiest is path finding.

    Give the npc 4 variables, 2 are its initial position. And for each npc on start of layout set these to its current coords.

    The easiest way to find the coords it wants to go to, are place it there, and copy it's numbers.

    However, an alternative method would be to have lots of tiny sprites littered around with a variable that relates to the npc who is walking between them. On start of layout, for each npc, pick the nearest sprite with the same variable number. Find path.

    Then npc on arrived, pick furthest sprite with the same var no.

    This method is good as it's like 2 lines of code for all npcs. All they need is corisdonding variables. Good luck.

    (Note* you can have pick random sprite for a more sporadic movement)

  • Aher0 thanks I'll try that.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)