You’re using a foreach loop as if it was an index based loop…
I don’t believe you can use “Wall” as an index.
Try converting to a Index loop
public GameObject[] GroundWallObjects;
void Start ()
{
GroundWallObjects = GameObject.FindGameObjectsWithTag ("Wall");
for (int i = 0; i < GroundWallObjects.Length; i++)
{
GetComponent<LevelScript>().GroundWallPosition _= GroundWallObjects*.transform.position;*_
* }* * }*
Well, you'll need another loop here, to compare each and every one of the vector, if one match, then you turn a boolean to true. Like so : bool wallHit = false; foreach (Vector3 wallPosition in GetComponent<LevelScript>().GroundWallPosition) { if (wallPosition == transform.position + new Vector3 (0, -1, 0)) wallHit = true; } if (wallHit) //deny movement
Well, you'll need another loop here, to compare each and every one of the vector, if one match, then you turn a boolean to true. Like so : bool wallHit = false; foreach (Vector3 wallPosition in GetComponent<LevelScript>().GroundWallPosition) { if (wallPosition == transform.position + new Vector3 (0, -1, 0)) wallHit = true; } if (wallHit) //deny movement
– jokim