Can you store multiple x or y coordinates from different gameobjects in one variable and then compare all the stored values in a function?
I'm working on a simple 2D tile game on a 5x5 grid. The player can move around on the grid, but not pass certain places with so called "Walls".
How can I collect all the x or y coordinates from all the different walls on the grid, and use them in the player code where the player checks if there are any walls in the place you want to move towards?
This is what I want: I'm not sure if it's possible, but I want to combine all the x coordinates from all the different walls in one variable "wallsX", and all the y coordinates from the used walls in a second variable "WallsY". Then I want to use those variables ("WallsX" and "WallsY") with multiple integers stored to see if any of the stored values are or are not equal to the player's x or y coordinates.
For example:
There are two walls:
Coordinates wall1: (x, y) = (0, 3)
Coordinates wall 2: (x, y) = (2, 3)
etc. (up to max 10 walls)
Variables that check all coordinates of the used walls:
"WallsX" which has the following values: 0 and 2
"WallsY" which has the following values: 3 and 3
Functions:
If any value in "WallsX" == ... (contains a statement with the player coordinates (tranform.position.x))
If any value in "WallsY" == ...(contains a statement with the player coordinates (tranform.position.y))
Thanks in advance.