I’m working on a project that integrates a character controller with physics and voxels. I’ve setup both sides but whenever I place the player above the voxels, it falls down as it should but it goes right through the voxels. How do I achieve voxels with physics?
Does this help any.
viewer.mode=FULLSCREEN
function setup()
assert(OrbitViewer, "Please include Cameras as a dependency")
scene = craft.scene()
v=scene.camera:add(OrbitViewer, vec3(10,0,0), 30, 0, 200)
v.rx,v.ry=10,-40
createCube(4,10,4)
scene.voxels.blocks:addAssetPack("Blocks")
error = scene.voxels.blocks:new("Error")
error.setTexture(ALL, "Blocks:Error")
scene.voxels:resize(vec3(1,1,1))
scene.voxels.coordinates = vec3(0,10,0)
-- create voxel floor
for x=1,6 do
for z=1,6 do
scene.voxels:fill("Error")
scene.voxels:block(x,0,z)
end
end
end
function draw()
update(DeltaTime)
scene:draw()
end
function update(dt)
scene:update(dt)
end
function createCube(x,y,z)
cube=scene:entity()
c1=cube:add(craft.rigidbody,DYNAMIC)
cube.position=vec3(x,y,z)
cube.model=craft.model.cube(vec3(1,1,1))
cube:add(craft.shape.box,vec3(1,1,1))
cube.material = craft.material(asset.builtin.Materials.Specular)
cube.material.map = readImage(asset.builtin.Blocks.Cactus_Inside)
end