How do I create random AI movement?

Get help using Construct 2

Post » Sun Mar 23, 2014 8:29 pm

Hi

I'm just starting out in Construct and I'm trying to work out how to create idle/random movement for the enemies in a top-down shooter style game.

Part of what I have looks like this:

Image

My hope was that this would make the enemies randomly change direction after a random time interval. What happens is that only one of the enemy instances perform the action, and the others do not.

Removing the "for each" condition makes them all perform the same random rotation at the exact same time, where I was hoping for a more varied outcome.

What am I missing here? Is there a better way to do this?

Any and all help is greatly appreciated :)

Thanks
B
8
S
2
Posts: 28
Reputation: 546

Post » Sun Mar 23, 2014 8:45 pm

Use for "pick random instance" instead of for each loop
B
12
S
4
G
1
Posts: 241
Reputation: 1,699

Post » Sun Mar 23, 2014 9:05 pm

Hey vagaev, thanks a lot! That certainly helped, it looks better now. The problem though is that this solution becomes dependent on how many enemies are in the layout - the more characters I have running around, the more seldom they'll get picked to perform their actions.

Is there a way to get them all to run their own separate little schedules of things they can go and when to do it, without becoming dependent on other factors like number of instances?

Hope that makes sense, not sure how to express what I'm after here :)

thanks!
B
8
S
2
Posts: 28
Reputation: 546

Post » Mon Mar 24, 2014 12:37 am

There are many solutions. The most logic one would be to use families and set this parameter for thatsaid family so it will affect everymonster.

But you can bypass it with Pick all & random (0,1)-> rotation

Hope that works

The pathfinder behavior might be an option too.
B
12
S
4
G
1
Posts: 241
Reputation: 1,699


Return to How do I....?

Who is online

Users browsing this forum: zsoldiers and 11 guests