@Simeon I haven’t tried this before, but I have a question here. I have a sphere bouncing between 2 cubes. The sphere bounces off the bottom cube and also bounces off the top cube. But if I comment out the createSphere line to remove the sphere, the top cube passes thru the bottom cube. Just curious why the cubes don’t collide, but they both collide with the sphere.
viewer.mode=FULLSCREEN
function setup()
assert(OrbitViewer, "Please include Cameras as a dependency")
scene = craft.scene()
skyMaterial=scene.sky.material
skyMaterial.sky=color(0, 62, 255, 255)
skyMaterial.horizon=color(99, 255, 0, 255)
scene.sun.rotation=quat.eulerAngles(20,45,-30)
v=scene.camera:add(OrbitViewer, vec3(0,0,0), 150, 0, 500)
v.rx,v.ry=10,20
createFloor()
createRect(0,15,0)
createSphere(0,0,0)
end
function draw()
update(DeltaTime)
scene:draw()
end
function update(dt)
scene:update(dt)
end
function createFloor()
floor=scene:entity()
f=floor:add(craft.rigidbody,STATIC)
f.restitution=1
floor.position=vec3(0,-20,0)
floor.model = craft.model.cube(vec3(100,1,100))
floor:add(craft.shape.model,floor.model)
floor.material = craft.material(asset.builtin.Materials.Standard)
floor.material.map = readImage(asset.builtin.Surfaces.Basic_Bricks_AO)
end
function createRect(x,y,z)
rec=scene:entity()
rc=rec:add(craft.rigidbody,DYNAMIC)
rc.restitution=1
rec.position=vec3(x,y,z)
rec.model = craft.model.cube(vec3(5,5,5))
rec:add(craft.shape.model,rec.model)
rec.material = craft.material(asset.builtin.Materials.Standard)
rec.material.map = readImage(asset.builtin.Surfaces.Basic_Bricks_AO)
end
function createSphere(x,y,z)
local sphere1=scene:entity()
local sph=sphere1:add(craft.rigidbody,DYNAMIC)
sph.restitution=1
sphere1.position=vec3(x,y,z)
sphere1.model = craft.model.icosphere(1,2)
sphere1:add(craft.shape.sphere,1)
sphere1.material = craft.material(asset.builtin.Materials.Specular)
sphere1.material.diffuse=color(0,0,255)
end