//Picks up a block of bridge pieces and teleports it to backpack void PickupABlockOfBridgePieces(Collider other) { Destroy(other.gameObject); for (int i = 0; i != piecesOfBridgeInOneBlock; i++) { BridgeShardNewPosition.Add(new Vector3(PlayerBackpackPosition.x, PlayerBackpackPosition.y + BackPackHeight + firstPieceLocationOnYAxis, PlayerBackpackPosition.z)); BridgeShardCopy = Instantiate(bridgeShard, BridgeShardNewPosition[BridgeShardNewPosition.Count - 1], Quaternion.Euler(0, Random.Range(0, 360), 0)); BridgeShardList.Add(BridgeShardCopy); BridgeShardList[BridgeShardList.Count - 1].transform.parent = transform.GetChild(3).transform; BackPackHeight++; } }
//Clearing last element of list and deleting bridge piece from backpack void RemoveBridgeShardFromBackpack(int lastElementInList) { Destroy(BridgeShardList[lastElementInList]); BridgeShardList.RemoveAt(lastElementInList); }