A better way to make a NPC AI with only constant alt value changing?

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.
  • I recently started working on an AI for my platformer project in which the NPC moves like the player's movement itself (using qualifiers). The movement engine works in a way that only the NPC moves depending on the value (for example, if the value is 1 the npc moves to the left, and with 2 it moves to the right, and 0 makes it gradually stop moving) What bothers me is that the AI code for switching between values seems to be really messy, and I even tried programming a "checker" where, if you get too many "0's" in a row (which means the NPC will stay standing for a long time as it randomly changes the value each time), it forces the value to either 1 or 2.

    And then the real problem comes around, when two or more NPCs are in the frame, they both sometimes move in the same direction but occasionally stop or shift to look in another direction, and animations seems to broke. (see attached gif)

    Either way, is there an easier or just a less dummy way to program this kind of AI that just uses values to move NPCs around and doesn't use random movement for each character?

  • And then the real problem comes around, when two or more NPCs are in the frame, they both sometimes move in the same direction but occasionally stop or shift to look in another direction, and animations seems to broke.

    That's a problem with your object selection. If you have multiple selected in an event, in most cases Fusion will pick the last created one to read the expressions from. A for-each loop fixes that, but has its own quirks of being sort of delayed in order of execution.

    You should read up on it in Volnaiskra's blog post about Please login to see this link..

    Darkwire Software Lead Programmer (C++ & C#)
    Please login to see this link. | Please login to see this link. | Please login to see this link. | Please login to see this link.

Participate now!

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