// returns the length of the created platform
private PlatformObject spawnPlatform(int localIndex, ObjectLocation location, Vector3 position, Vector3 direction, bool activateImmediately)
{
PlatformObject platform = (PlatformObject)infiniteObjectManager.objectFromPool(localIndex, ObjectType.Platform);
platform.orient(position + (direction * platformSizes[localIndex].z / 2), Quaternion.LookRotation(direction));
int objectIndex = infiniteObjectManager.localIndexToObjectIndex(localIndex, ObjectType.Platform);
InfiniteObject prevTopPlatform = infiniteObjectHistory.objectSpawned(objectIndex, 0, location, ObjectType.Platform, platform);
// the current platform now becames the parent of the previous top platform
if (prevTopPlatform != null)
{
prevTopPlatform.setInfiniteObjectParent(platform);
}
else
{
infiniteObjectHistory.setBottomInfiniteObject(location, false, platform);
}
infiniteObjectHistory.addTotalDistance(platformSizes[localIndex].z, location, false);
if (activateImmediately)
{
platform.activate();
}
return(platform);
}