Go to random instances of a family constantly?

  • I'm trying to make an enemy which should loot random objects on map.

    The enemy has a pathfinder behaviour.

    I've added a boolean to the loot family which indicates the item looted or not.

    The enemy should choose a random item and go towards it.

    When it arrived, the boolean variable of the item should switched to false.

    Then the enemy should choose another item which is not looted.

    How can I do this?

    Thanks.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Add an instance variable LootUID to the enemy.

    For each Enemy (or some other event that picks an Enemy)
     LootFamily boolean isLooted NOT set
     System Pick random LootFamily (or pick nearest to enemy)
     ... Enemy set LootUID to LootFamily.UID
     ... Enemy Find Path to (LootFamily.X, LootFamily.Y)
    
    
    Enemy on arrived
     LootFamily pick by unique ID (Enemy.LootUID)
     ... LootFamily set isLooted to true
    

    You can also add another boolean variable to the loot family to mark it as "about to get looted", if you don't want several enemies to chase the same loot.

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