timer = 0.0
maxTime = 3.0
explosionRadius = 25.0
explosionDamage = 10
baseExplosionStrength = 1000.0
function tick(elapsed)
timer = timer + elapsed
if(timer >= maxTime) then
explode()
end
end
function explode()
--note that adding an object in a script uses the exact same
--table structure as scene files do, which is a nice consistency
explosionObj = scene.addObject({
transform = {
position = transform.getPos(this),
rotation = vector3(0, 0, 0),
scale = vector3(1, 1, 1)
},
luaScript = "Scripts/explosion.lua",
resources = { "tick", "physics", "scene" },
rigidbody = {
shape = {
type = "sphere",
radius = explosionRadius
},
mass = 0,
kinematic = true,
collisionRespone = false
}
})
addValueTo(explosionObj, "explosionDamage", explosionDamage)
addValueTo(explosionObj, "baseExplosionStrength", baseExplosionStrength)
scene.removeObject(this)
end