How do I create semi-complex AI?

Get help using Construct 2

Post » Thu Jan 07, 2016 11:35 pm

I'm wanting a sprite to patrol certain parts of the game and run away when it spots the player, but not run to a specific destination. Any Ideas? Thanks in advance~

I currently have the sprite on a timer, every random(1,3) seconds picking random(layout.height) & random(layout.width)

When it spots the player, the speed amps up, but it doesn't make an effort to get out of danger of the player. Thats what I'm aiming for.
B
25
S
10
Posts: 130
Reputation: 2,191

Post » Thu Jan 07, 2016 11:54 pm

People are going to ask for screenshots or a .capx or a better explanation. Is this a top-down game? Platformer? What kind of behavior does this Sprite have?

Assuming it's a top-down game, you can add a Line-of-sight behavior to the Sprite, and when it has a line-of-sight to whatever target you want, have a set of events happen, such as running faster.
B
8
S
1
Posts: 39
Reputation: 536

Post » Thu Jan 07, 2016 11:55 pm

line of sight = set angle towards (player.x, player.Y) (toggle inverted) to make it work.
B
29
S
14
G
10
Posts: 357
Reputation: 8,406

Post » Thu Jan 07, 2016 11:55 pm

Its not a top down platformer, the player uses the 8 direction controls
B
25
S
10
Posts: 130
Reputation: 2,191

Post » Thu Jan 07, 2016 11:57 pm

Carbincopy wrote:line of sight = set angle towards (player.x, player.Y) (toggle inverted) to make it work.


Now this would work, but it has obstacles to get around. And within 1-3 seconds, it would find a new path.
B
25
S
10
Posts: 130
Reputation: 2,191

Post » Fri Jan 08, 2016 12:27 am

add a wait time to before it goes back to it's path finding or it will still keep running as long as in line of sight of player and always runs from the player.X, player.Y
B
29
S
14
G
10
Posts: 357
Reputation: 8,406

Post » Fri Jan 08, 2016 12:48 am

Carbincopy wrote:add a wait time to before it goes back to it's path finding or it will still keep running as long as in line of sight of player and always runs from the player.X, player.Y


The expression "set angle towards (player.x, player.Y) (toggle inverted)" Toggle inverted? It doesn't recognize it.
B
25
S
10
Posts: 130
Reputation: 2,191

Post » Fri Jan 08, 2016 1:12 am

Try this set angle AISprite.Angle-Player.X&Player.Y
B
29
S
14
G
10
Posts: 357
Reputation: 8,406

Post » Fri Jan 08, 2016 1:28 am

Thanks, I'll try it out
B
25
S
10
Posts: 130
Reputation: 2,191

Post » Fri Jan 08, 2016 2:45 am

Could I suggest:

enemy Is on-screen
if player.x<self.x simulate 8-direction moving right
else simulate 8-direction moving left
if player.y>self.y simulate 8-direction moving up
else simulate 8-direction moving down
Eh, Steve!
B
118
S
54
G
13
Posts: 115
Reputation: 16,244

Next

Return to How do I....?

Who is online

Users browsing this forum: blackhornet, inozz, odiusfly, TheMob000, YoHoho, zebios and 1 guest