[SOLVED] How to count number of object with specific value and assign random value to it?

I have an object called “Land” it has 2 variables

  1. Index (Number)
  2. Unlock (Boolean)

image
For example I place 6 Land objects
If I press “F” key I want it to count how many lands are unlocked.
(boolean unlocked = true)

Then each of my object has a default Index variable value of 0
What to do if I want to assign the value into Index variable like this
Randomly Pick a land object, set its value 1
Pick different object, set to 2
repeatedly until it reach my maximum count for unlocked land (in this case 6 but I want it to be dynamic and scalable)

At the end when I press “F” the system count each unlocked object
Then every object that is unlocked will be given Index value that is different from others.

Please help, thank you.

Hey hey, this event should do it:

Use a condition to filter the unlocked lands, and the “PickedInstancesCount()” function in the actions:


Do you want to select a random unlocked land object, or any land object? I’ll assume the former, in which case use:

Haha, beaten by a few minutes, and almost an identical solution :smiley:

Hahaha I know right :joy:

Thank you guys, It works !!! :smile: