lukezero's Recent Forum Activity

  • If you just want to pick the closest enemy then:

    Enemy: pick closest to (player.x, player.y)

    Or if you want to pick all the enemies within a certain distance of the player:

    System: pick by comparison: enemy: distance(enemy.x,enemy.y,player.x,player.y)<100

    I personally wouldn’t want to touch any code that ai generates. Mainly because debugging is hard and time consuming. I find it easier to try to understand what I code as I go so I’m able to fix things as I go. I have no way of verifying how correct, robust or bug free a piece of ai code is without dissecting it which sounds like an annoying waste of time.

    It's working!

    You are the man!

  • System: pick by comparison: enemy: distance(enemy.x,enemy.y,player.x,player.y)<100

    In this case, is it better for enemies to be alone or grouped together in a family?

  • If you just want to pick the closest enemy then:

    Enemy: pick closest to (player.x, player.y)

    Or if you want to pick all the enemies within a certain distance of the player:

    System: pick by comparison: enemy: distance(enemy.x,enemy.y,player.x,player.y)<100

    I personally wouldn’t want to touch any code that ai generates. Mainly because debugging is hard and time consuming. I find it easier to try to understand what I code as I go so I’m able to fix things as I go. I have no way of verifying how correct, robust or bug free a piece of ai code is without dissecting it which sounds like an annoying waste of time.

    Thanks, dude!

    I want the routine to calculate the distance of each enemy to the player character and the drone (the green square) to activate them in an order of proximity.

  • Hi guys!

    I'm raising this question here for several reasons:

    1. I know that many programmer friends use AIs successfully with other languages/engines;

    2. As a designer, I usually use "no code" engines to produce my games and only now have I been testing this AI for this purpose.

    3. I ask because in my first tests, I found some inconsistencies in the code suggested by ChatGPT.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi guys!

    I'm trying to implement a routine for my top-down game, in which a flying enemy activates disabled enemies near the player character, in order of proximity.

    I tried to create a routine with the help of ChatGPT, but I believe he made mistakes in some commands (but he was right when recommending the use of Array).

    Below is an image so you can better understand the mechanics I am trying to program.

    Tagged:

  • Like this:

    I also made some adjustments to the demo which include this, and made some tweaks to some values, such as the pathfinding refresh rate. It was at every 0.02 seconds, but that appears to be pretty memory heavy so I changed it to 0.05.

    It also seems to work better with 4 directional movement.

    https://drive.google.com/file/d/1nDI-BU8huVVyZSzPvkEFd0nZLw6xFY-e/view?usp=drive_link

    Thank you very much!!! :D

  • Adding this should help you achieve the effect:

    Also consider increasing the rotation speed so the characters quickly snap into the correct angle.

    As for the animations, all you need to do is check the angle of the Player/Enemy Controllers and apply the animation to the characters based on that.

    - For example, if Enemy_Controller angle is between 315 and 45, set Enemy animation to "Right".

    You can use the condition "Pick Children" to access the Graphic object belonging to the controller.

    - For example: Condition1 -> Enemy_Controller -> Pick Children -> Enemy.

    Condition2 -> Enemy_Controller angle is between 315 and 45

    Action: Enemy -> Set Animation to "Right"

    Since you used the Condition 1 to specifically pick the child of the Enemy_Controller, it will only change the animation if it's its own child.

    Same applies to the Player.

    Thanks again! You're awesome! :D

  • Do you need only the graphics to turn in 4 directions, or do you want to restrict the movement to only Up, Left, Right and Down?

    Both things, but only the necessary programming to make it functional in this way.

  • I made a small improvement to fix an issue where they would still get stuck in the wall sometimes. Use this version instead:

    https://drive.google.com/file/d/1nDI-BU8huVVyZSzPvkEFd0nZLw6xFY-e/view?usp=drive_link

    Do you think it works well with the enemy moving in 4 directions?

  • I made a small improvement to fix an issue where they would still get stuck in the wall sometimes. Use this version instead:

    https://drive.google.com/file/d/1nDI-BU8huVVyZSzPvkEFd0nZLw6xFY-e/view?usp=drive_link

    Thanks again! Already downloaded! :D

  • Here's an example I made using the pathfinding behavior.

    It has some extra stuff to add a bit of polishing that you may find useful.

    The code is fully commented to great detail, so it should be easy to understand.

    https://drive.google.com/file/d/1nDI-BU8huVVyZSzPvkEFd0nZLw6xFY-e/view?usp=drive_link

    Thanks, dude!

    I'll test and study it right now! :D

  • Since the logic you are going for is enemy following the player then use the Pathfinding behaviour. The enemy won't get stuck on walls with this.

    I've tried many times and it's bugged. :(

lukezero's avatar

lukezero

Member since 4 Oct, 2014

None one is following lukezero yet!

Trophy Case

  • 10-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

14/44
How to earn trophies