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?
Develop games in your browser. Powerful, performant & highly capable.
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.