Tiny Heist: Tile guard AI

  • Hello again,

    I was trying to duplicate a game called Tiny Heist (https://www.coolmathgames.com/0-tiny-heist), but I'm having some issues with the guard AI. I have the basic movement down, but they don't work right in the corners. If they are overlapping a wall/door in front of them, they are only suppose to be able move the clear way. For some reason, they are apparently being able to turn any direction. Can someone figure out what is wrong with this? I have uploaded a basic example. In the example, hold Z to trigger the movement. dropbox.com/s/5t0i6fp8v66wsuv/Guard%20AI.c3p

    Thanks,

    Give me a Pixel

    Tagged:

  • Looks like you are checking overlaps too quickly within the tick like maybe before the unit has properly moved. If I move the overlap checks into a separate function, wait and then run it then it works perfectly.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'll try that. Thanks

    EDIT: I'm not exactly certain what you mean. The guard has to check if he can move before he moves. Could you please upload a modified version of the file I provided or some screenshots?

    Thanks again,

    Give me a Pixel

  • I simplified things a bit. Dunno if I went overboard and altered your original idea of movement by mistake...

    drive.google.com/open

  • I just meant that you check if enemy is not overlapping anything and do the move, and the following check about enemy is overlapping and choose a direction happens all within the same move and it's too fast. So it moves the enemy down one space, then checks if overlapping and alters the direction, this always results in choosing the last condition where it chooses left or right because it's not detecting overlaps correctly.

    So what I did was allow the enemy to move on the is not overlapping check, then add a small wait, then call a function. The wait is because you are setting a position and there is no condition like 'has moved'. The separate function called has all of the 'is overlapping' checks to then determine if the enemy is now overlapping anything once landed.

    FYI if you edit a post I don't get notified of anything.

  • Thank you both. I will try those ideas out and see what I get.

  • Magistross

    That works better, but the guards still can still turn completely around even if they have an opening one one or two sides of them.

    I tried that, and they went absolutely haywire. I probably didn't do it right, but it didn't work. I'll have to keep trying. Also a file would be nice if you got it working.

  • Give me a Pixel

    Did some tweaking. Removed the ability to do a 180, unless that's the only move possible.

    File was updated.

    drive.google.com/open

  • Thank you. That works perfectly.

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