Graphics Reference
In-Depth Information
// call the function to take care of spawning all the
// players and putting them in the right places
CreatePlayers( theParentObj, totalPlayers );
}
public void CreatePlayers ( Transform theParent, int totalPlayers )
{
playerTransforms=new ArrayList();
playerGameObjects=new ArrayList();
for(int i=0; i<totalPlayers;i++)
{
// spawn a player
tempTrans= Spawn ( playerPrefabList[i],
startPositions[i], startRotations[i] );
// if we have passed in an object to parent the
// players to, set the parent
if(theParent!=null)
{
tempTrans.parent= theParent;
// as we are parented, let's set the local
// position
tempTrans.localPosition= startPositions[i];
}
// add this transform into our list of player
// transforms
playerTransforms.Add(tempTrans);
// add its gameobject into our list of player
// gameobjects (we cache them separately)
playerGameObjects.Add (tempTrans.gameObject);
}
}
public GameObject GetPlayerGO (int indexNum)
{
return (GameObject)playerGameObjects[indexNum];
}
public Transform GetPlayerTransform (int indexNum)
{
return (Transform)playerTransforms[indexNum];
}
public Transform Spawn(GameObject anObject, Vector3 aPosition,
Quaternion aRotation)
{
// instantiate the object
Search WWH ::




Custom Search