PickedInstanceCount() Problem

Let’s say I have 100 visible enemies, my PickedInstanceCount() Counts every visible enemy . Now in the next frame every enemy is invisible. The PickedInstanceCount() Value still is 100 since the condition is not met anymore therefore it stops counting.

This is a big problem in my case. using reverse condition or sceneinstancecount() does not work either.

Is there a workaround?

Helpful Comments:
by @MrMen

The function PickedInstanceCount() selects all instances of an object that meet specified event conditions, irrespective of their visibility (whether they are visible or hidden).

@Keith_1357

My instinct is that your event is setting a variable to the number of visible or hidden objects. The issue could be that conditions work on 2 levels. They decide if something is true or false and also pick the true objects. If there aren’t any matches then it won’t trigger the action(s) So, the variable remains to what it was the last time it was true.

Now, you can probably use not but it’s just as easy to set the variable to zero (or some other value depending on your setup) and then change it if the condition is met.

Set v to 0
If object is visible then set v to picked count

I don’t understand what your exact problem is. PickedInstanceCount() selects all the instances of an object that have met the event conditions, regardless of whether they are visible or hidden.

Can you screen shot your events that include the PickedInstanceCount() and the filtering conditions?

1 Like

Let me clarify: when the condition is to “count every visible enemy,” the expected behavior would be for pickedinstancecount() to return 0 if all 100 enemies are invisible. However it incorrectly maintains the count at 100. This issue persists even on an individual level; for instance, if the last visible enemy becomes invisible, the counter should drop from 1 to 0, but it incorrectly remains at 1 even tho now every enemy is invisible.

I’m surprised this hasn’t been addressed or discussed before. Is there something I’m overlooking? Is there a known workaround or a fix for this issue?

Can you post a screenshot of your event(s)

My instinct is that your event is setting a variable to the number of visible or hidden objects. The issue could be that conditions work on 2 levels. They decide if something is true or false and also pick the true objects. If there aren’t any matches then it won’t trigger the action(s) So, the variable remains to what it was the last time it was true.

Now, you can probably use not but it’s just as easy to set the variable to zero (or some other value depending on your setup) and then change it if the condition is met.

Set v to 0
If object is visible then set v to picked count

1 Like

Has the problem been resolved, or is it still an issue? If it’s still happening, can you screen shot the events?