// returns true if there is still space on the platform for a collidable object to spawn private void spawnCollidable(ObjectType objectType, Vector3 position, Vector3 direction, ObjectLocation location, PlatformObject platform, int platformLocalIndex, bool activateImmediately) { int collidablePositions = platform.collidablePositions; // can't do anything if the platform doesn't accept any collidable object spawns if (collidablePositions == 0) { return; } Vector3 offset = platformSizes[platformLocalIndex] * 0.1f; float zDelta = platformSizes[platformLocalIndex].z * .8f / (1 + collidablePositions); for (int i = 0; i < collidablePositions; ++i) { if (platform.canSpawnCollidable(i)) { int localIndex = infiniteObjectManager.getNextObjectIndex(objectType, spawnData); if (localIndex != -1) { InfiniteObject collidable = infiniteObjectManager.objectFromPool(localIndex, objectType); collidable.orient(platform, position + (offset.z + ((i + 1) * zDelta)) * direction + platform.getRandomSlot() * slotDistance, Quaternion.LookRotation(direction)); int objectIndex = infiniteObjectManager.localIndexToObjectIndex(localIndex, objectType); infiniteObjectHistory.objectSpawned(objectIndex, (offset.z + ((i + 1) * zDelta)), location, objectType); platform.collidableSpawned(i); if (activateImmediately) { collidable.activate(); } // don't allow any more of the same collidable type if we are forcing a different collidable if (platform.forceDifferentCollidableTypes) { break; } } } } }