Search Unity

Comparing the elements of an array with the same tag, assigning int to gameobject

Discussion in 'Scripting' started by Younis4x, Jul 5, 2022.

  1. Younis4x

    Younis4x

    Joined:
    Jul 5, 2022
    Posts:
    1
    Hi guys,
    The purpose of my game is that i want the player to open one of the 10 chests laid around him and it will give him a random number, if that random number is equal to the player's unique number then it will activate an event, simple enough right? well i got into some problems due to my low knowledge on c# and gameObjects, i already made an array for the random numbers and it's working, and i also made an array for the chests and i gave them all the same tag "Box", so how can i link my 10 random integers to each one of the elements inside the chest array, one last thing is how can i know which chest was opened and compare it since they all have the same tag, is there a better approach for this?