How do I create random AI movement?

0 favourites
  • 4 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • 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:

    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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Use for "pick random instance" instead of for each loop

  • 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!

  • 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.

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