Is this workshop variable bug?

variable
{
player:
47: player_in_game
49: current_target
}

action
{
Event Player.current_target = First Of(Sorted Array(Filtered Array(Filtered Array(All Players(Team 2),
Current Array Element.player_in_game == True), Is Alive(Current Array Element) == True), Distance Between(Event Player,
Current Array Element)));
}

i made a PVE game, the dummy bot will attack who is in Event Player.current_target,but i foun there is a weird bug havent met before, that is Event Player.current_targe sometimes contains the spectator, no matter how many filtered array i use. how to get rid off this annoying problem?

I’m not sure about spectators, but the way that’s currently set up your bot might be able to target unspawned players. You also don’t need to use nested filtered arrays. You can just use an and as the condition in the first filtered array.

Squ1dward is right, you can check “has spawned” and “is exist” and “is alive” for be sure that target is totally have “character” and alive.
in some reasons when players enter to lobby and didn’t have spawned(like in selected hero menu) game see them as “alive”.

Yeah don’t do 2 filtered arrays like that, heck I’m not even sure if that works properly at all. But instead, use && (and) with both your conditions in the single filtered array. Is Alive should work fine. Everything else looks fine.

Also tbh add another &&, with “has spawned(current array element) = true”.

1 Like

Isn’t exactly a bug, because spectator is a regular player that don’t possesses an hero entity, but still ingame. You can use when player left match event and attempt to unset all references to that player for all.