check if arrays share any value without a for loop

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By lettucing

i have a lot of objects and a tile, all of them have an array called “tags”

when colliding, i want to see if the tags of the objects share a tag with the tile

how can i do this without using a for loop, as i feel as it would cause the game to slow down due to the amount of objects being checked

:bust_in_silhouette: Reply From: Mitcha47

Start with a for loop with a comparison to see if that effects performance as badly as you assume.

If a for loop isnt efficient enough, then you can try two simple changes to see if that improves your game.

  1. Implementing your tags with integers.
  2. Utilizing masks and layers if your objects are CollisionObjects