[FIXED]
Ive looked at alot of different threads and I think its just me not understanding it, and what im doing wrong.
Anyways the issue is, I have a parent object(Playerhand, I create a prefab in code(blankCard) and i put the object as a child of the parent.)
Now What I want to do is be able to go through all the child objects of the parent and offset each of their x position from the last child.
heres my code
void DrawCard()
{
GameObject Playerhand = GameObject.Find ("PlayerHand");
Vector3 cardposition = Playerhand.transform.position;
int index = Random.Range(0,Collection.Count);
int childcount = Playerhand.transform.childCount;
GameObject newCard = Instantiate(blankCard, transform.position + cardposition, transform.rotation) as GameObject;
newCard.transform.parent = Playerhand.transform;
newCard.gameObject.GetComponent<SpriteRenderer>().sprite = Collection[index].cardSprites[0];
Collection.RemoveAt(index);
}