// spawn a scene object at the specified location private void spawnSceneObject(int localIndex, ObjectLocation location, Vector3 position, Vector3 direction, bool activateImmediately) { SceneObject scene = (SceneObject)infiniteObjectManager.objectFromPool(localIndex, ObjectType.Scene); scene.orient(position + direction * sceneSizes[localIndex].z / 2, Quaternion.LookRotation(direction)); localSceneDistance[(int)location] += sceneSizes[localIndex].z; int assocaitedPlatformLocalIndex = infiniteObjectHistory.getFirstPlatformIndex(); PlatformObject associatedPlatform = infiniteObjectManager.localIndexToInfiniteObject(assocaitedPlatformLocalIndex, ObjectType.Platform) as PlatformObject; if (associatedPlatform.slope != PlatformSlope.None) { localSceneHeight[(int)location] += platformSizes[assocaitedPlatformLocalIndex].y; } int objectIndex = infiniteObjectManager.localIndexToObjectIndex(localIndex, ObjectType.Scene); InfiniteObject prevTopScene = infiniteObjectHistory.objectSpawned(objectIndex, 0, location, ObjectType.Scene, scene); // the current scene now becames the parent of the previous top scene if (prevTopScene != null) { prevTopScene.setInfiniteObjectParent(scene); } else { infiniteObjectHistory.setBottomInfiniteObject(location, true, scene); } infiniteObjectHistory.addTotalDistance(sceneSizes[localIndex].z, location, true); if (scene.sectionTransition) { infiniteObjectHistory.didSpawnSectionTranition(location, true); } if (activateImmediately) { scene.activate(); } }