Help for loop changes more then i want.

Oke so want to change a string inside a object which is inside an array. But what happens is it also changes the strings of the objects that have a higher index then the one I try to change. The problem is here " playPieceScript.playPieceList*[1].swiping = “Swipe” + mouseScript.finalDirection;" I try to only chage index 3 but when I print out the results it changes not index 1-2 but 3-7.*

  • #region importScripts*

  • MouseClass mouseScript;*

  • PlayPiece playPieceScript;*

  • #endregion*

  • bool selectingPiece = true;*

  • void Start()*

  • {*

  •   playPieceScript = Camera.mainCamera.GetComponent<PlayPiece>();*
    
  •   mouseScript = Camera.mainCamera.GetComponent<MouseClass>();*
    
  • }*

  • void Update ()*

  • {*

  •   CollisionCheck();*
    
  • }*

  • void CollisionCheck()*

  • {*

  •   Ray ray = Camera.mainCamera.ScreenPointToRay(Input.mousePosition);*
    
  •   RaycastHit hit;*
    

_ Debug.DrawRay(ray.origin, -Vector3.up * 10, Color.cyan);_

  •   for(int i = 0; i < playPieceScript.playPieceList.Count; i++)*
    
  •   {*
    
  •   	for(int ii = 0; ii < 7; ii++)*
    
  •   	{*
    
  •   		if(Physics.Raycast(ray, out hit))*
    
  •   		{	*
    

_ if(hit.collider == playPieceScript.playPieceList*[ii].playPiece.collider*_
_ && playPieceScript.playPieceList*[ii].playPiece.renderer.enabled == true*
* && playPieceScript.actionState == “Neutral”)
{
if(mouseScript.swipe == true)
{
print(“1”);
mouseScript.swipe = false;
playPieceScript.playPieceList[3].swiping = “Swipe” + mouseScript.finalDirection;
playPieceScript.actionState = “Swiping”;
}
}
}
}
}
}
}*

Thank you for the help in advance!_

Yes, so ofcourse I used ii first. But then the problem already occourd, so I though it had somthing to do with the loop so I changed it to 3 so there was no possible way it could change the indexes of 3-7. But what it prints out is

1
NotSwiping
NotSwiping
NotSwiping
SwipeRight < this one should be changed to SwipeRight < and is index 3
SwipeRight < but it shouldnt do anything with these
SwipeRight < but it shouldnt do anything with these
SwipeRight < but it shouldnt do anything with these

And also I placed an print in the if(mouseScript.swipe == true) but that prints out only once.

Check to make sure that all 4 array entries are not, in fact, referencing the same object.

My guess is that they are.