Best solution for enemy AI?

Get help using Construct 2

Post » Mon Jun 10, 2013 11:00 pm

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.CoffeeOD2013-06-11 00:15:52
B
7
S
1
Posts: 51
Reputation: 1,087

Post » Tue Jun 11, 2013 12:13 am

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 enabledbreackzin2013-06-11 00:19:18
B
7
S
3
G
1
Posts: 154
Reputation: 1,812

Post » Tue Jun 11, 2013 2:40 pm

@CoffeeOD
Worked?
B
7
S
3
G
1
Posts: 154
Reputation: 1,812

Post » Tue Jun 11, 2013 6:55 pm

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.
B
49
S
12
G
10
Posts: 1,833
Reputation: 14,538

Post » Tue Jun 11, 2013 8:32 pm

[QUOTE=breackzin] 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[/QUOTE]
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!

[QUOTE=BluePhaze] 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.[/QUOTE]
I did thought about markers, but attempts doing so have been poor when dealing with multiple enemies. Will keep looking then.
B
7
S
1
Posts: 51
Reputation: 1,087


Return to How do I....?

Who is online

Users browsing this forum: AllanR, Artpunk, oosyrag, QuantumMMX and 8 guests