--random cubes variables
randomCubeArea = {
center = vector3(20, 14.2, 0),
halfSize = vector3(21.49, 9.75, 7.23)
}
randomCubeCount = 25
randomCubeSizeRange = {
min = 1.0,
max = 4.0
}
randomCubeDensity = 0.75
--helper function for random floating point number in a range
function randomFloat(min, max)
return min + ((max - min) * math.random())
end
--random cube addition function
function addRandomCube()
minArea = randomCubeArea.center - randomCubeArea.halfSize
maxArea = randomCubeArea.center + randomCubeArea.halfSize
currentScale = randomFloat(randomCubeSizeRange.min, randomCubeSizeRange.max)
objectTable = {
transform = {
position = vector3(randomFloat(minArea.x, maxArea.x), randomFloat(minArea.y, maxArea.y), randomFloat(minArea.z, maxArea.z)),
rotation = vector3(0,0,0),
scale = vector3(currentScale,currentScale,currentScale)
},
model = models.testCube,
luaScript = "Scripts/Damagable.lua",
resources = { "scene" },
rigidbody = {
shape = {
type = shapeNames.box,
size = vector3(2,2,2)
},
mass = currentScale * currentScale * currentScale * randomCubeDensity
}
}
table.insert(scene.objects, objectTable)
end
--adding the actual cubes
for i=1,randomCubeCount do
addRandomCube()
end