How do I use "on arrive" for the path finder behavor.

  • I've made something of a life sim. It works okay.

    I have the NPC's do things depending on the value of instance variables.

    So, I have hunger, thirst, toilet, and entertainment. Those values start at 10, and

    when they get below 4, the npc must go to the associated need.

    I also have an 'Action' text variable that checks what the npc is doing.

    so, when the npc gets to say, the shower, or water, the 'Action' variable' will switch to

    'Showering' or 'Drinking'

    I also have ones called 'Walking to x'. So, like, 'Walking to water' or, 'Walking to t.v' .

    The only problem is that I'm having trouble figuring out how to have it so, once the

    npc gets to the location, it stops. I've by passed this somehow. I probably set path finding 'Set to disabled' on collision or something. I can't remember and Construct didn't save the damn thing properly. Anyway, its still confusing for the npc, and myself, as when I check the 'Action' variable, it can't seem to make up its mind.

    I would like to figure out how to make the npc finish the task before moving on to the next.

    Also, how do I have certain things have more of a priority over other things?

    So, for an example, thirst, and food, is obviously more important than entertainment.

    It still worked, but it didn't seem efficient for when I want to add animations and such.

  • So when the NPC reaches the location (water) it doesn't stop and continues to walk?

    There is probably something wrong with your code, it's hard to tell without seeing it.

    Maybe you are interfering with the sequence of pathfinding events somehow, for example calling "find path" repeatedly while NPC is still moving or something like that.

    For priority you can add some kind of ImportanceFactor. Say, for thirst set it to 1, for food 0.8, for tv 0.3

    Then to determine which action NPC should take, divide each instance variable by ImportanceFactor, for example:

    hunger=3 / 0.8 = 3.75

    thirst=3 / 1 = 3

    tv=2 / 0.3 = 6.66

    So the NPC should go drink first.

  • Thanks. Thats a good idea, actually for the priority.

    I'll add the capx drive.google.com/drive/folders ... Waryk-pGYr youre probably right but I'm not sure how to correct it.

  • justintime0185 your link is broken, try posting it without the "https://" part

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yes. The problem is that the event seems to repeat over rand over again. I notice that 'finding the path' is constantly switching between 'True' and 'false'.

  • Please share the working link to your capx

  • thanks folks (Sorry for the late response.)

    I The reason why I couldn't really share it was because I had lost the damn thing. But I'm going to test that same idea out again. With new knowledge!

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