void MovePassengers() { List <Transform> entityAbove = myController.CheckVertical(passengerLayers, 1, 0.025f); //Transform entitySide = myController.CheckHorizontal(passengerLayers, (int)Mathf.Sign(newPos.x)); if (entityAbove != null) { foreach (Transform trans in entityAbove) { if (trans.GetComponent <Controller2D>() && !myEntities.Contains(trans.GetComponent <Controller2D>())) { myEntities.Add(trans.GetComponent <Controller2D>()); //passengerList.Add(entityAbove, entityAbove.GetComponent<Controller2D>()); } } } /*if(entitySide) * { * if(entitySide.GetComponent<Controller2D>()&&!myEntities.Contains(entitySide.GetComponent<Controller2D>())) * { * //myEntities.Add(entitySide.GetComponent<Controller2D>()); * } * }*/ for (int i = 0; i < myEntities.Count; i++) { if (myEntities[i].CheckVertical(1 << gameObject.layer, -1) == null) { myEntities.Remove(myEntities[i]); Debug.Log("removed 1"); break; } } for (int i = 0; i < myEntities.Count; i++) { if (myEntities[i].CheckVertical(1 << gameObject.layer, -1).Contains(transform) && myEntities[i].raycastOrigins.bottomLeft.y >= GetComponent <BoxCollider2D>().bounds.max.y - 0.05f) { myEntities[i].transform.Translate(newPos); } } }