Best solution for enemy AI?

0 favourites
  • 5 posts
From the Asset Store
Best car suspension with spring effect and very cool terrain generation.
  • Im creating top-down game where character has 8-directional movement, enemies should follow players while avoiding walls etc. things which are set as obstacles.

    I tried pathfinder but found it bit akward to use as I need almost continuess path updating, even tried to update path upon "arrived" was triggered but enemies were too slow to turn around and got stuck at solid obstacles when path was narrow(ish).

    Best option seems to use simple set angle to player > move forward, but by default enemies will ignore all obstacles. Has anyone succeeded in making enemy AI including avoiding obstacles WITHOUT pathfinder plugin?

    Any tips about pahtfinder are also welcome, best scenario would be without third party plugins as Im planning to upload game to Scirra arcade.

  • everytick, globalvar"free"=0:> use acceleration towards player

    on collision with obstacles, trigger once:> set custommovement disable, set globalvar"free"=1, pathfind to "player last position"

    On collision with "player last position", globalvar"free"=1, trigger once:> set globalvar"free"=0, set custommovement enabled

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • CoffeeOD

    Worked?

  • You can also use invisible sprites as way points and have your enemies move toward them in order. You can then add logic to the enemies to stop moving to the way points when the player comes within a certain distance. There are plenty of examples of this type of AI pathfinding without the pathfinding behavior around the forums. Keep looking, you will find them.

  • everytick, globalvar"free"=0:> use acceleration towards player

    on collision with obstacles, trigger once:> set custommovement disable, set globalvar"free"=1, pathfind to "player last position"

    On collision with "player last position", globalvar"free"=1, trigger once:> set globalvar"free"=0, set custommovement enabled

    I tried to make sense of this (still bit akward around events tbh), but couldnt get enemy to move towards enemy after hitting obstacle (without using pathfind move along), but I keep trying to hammer my brains to understand, thanks for the help!

    You can also use invisible sprites as way points and have your enemies move toward them in order. You can then add logic to the enemies to stop moving to the way points when the player comes within a certain distance. There are plenty of examples of this type of AI pathfinding without the pathfinding behavior around the forums. Keep looking, you will find them.

    I did thought about markers, but attempts doing so have been poor when dealing with multiple enemies. Will keep looking then.

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