Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for i=2, count do
- newObj = nil
- if positions ~= nil then
- newObj = object.clone({position = positions[i]})
- else
- newObj = object.clone({position = {x = math.random(0, xMax) * step + start.x, y = start.y, z = math.random(0, zMax) * step + start.z}})
- end
- Wait.condition(function() terrainBag.putObject(newObj) end, function() return checkLoaded(newObj) end)
- Wait.condition(function() checkBounds(object) end, function() return checkLoaded(object) end)
- end
- function checkBounds(object)
- local bounds = object.getBounds()
- local pos = object.getPosition()
- local hitList = Physics.cast({
- origin = {pos.x, pos.y, pos.z},
- direction = {0,-1,0},
- type = 3,
- size = {bounds.size.x, bounds.size.y, bounds.size.z},
- max_distance = 5,
- debug = true
- })
- for _, entry in ipairs(hitList) do
- local offsetX = 0.905
- local name = entry.hit_object.getName()
- print(name)
- if name ~= object.getName() and name ~= "Table" then
- local bounds = entry.hit_object.getBounds()
- local new_pos = {bounds.center.x - offsetX * 6, 1.5, pos.z}
- object.setPosition(new_pos)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement