Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Handling 3D Collisions

Why is it that whenever I try to get an entity with a DYNAMIC rigid body collide with another rigid body, it just goes straight through the object? Could someone please tell me how to fix this?

Thanks in advance :)

Comments

  • dave1707dave1707 Mod
    Posts: 9,441
    viewer.mode=FULLSCREEN
    
    function setup()
        assert(OrbitViewer, "Please include Cameras (not Camera) as a dependency")
        size=1
        fill(255)
        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)
        createObjects()
        v=scene.camera:add(OrbitViewer, vec3(0,0,0), 30, 0, 200)
    end
    
    function createObjects()
        sphere1=scene:entity()
        s1=sphere1:add(craft.rigidbody,DYNAMIC)
        s1.restitution=1
        sphere1.position=vec3(0,5,0)
        sphere1:add(craft.shape.sphere,size)
        sphere1.model = craft.model.icosphere(size,2)
        sphere1.material = craft.material(asset.builtin.Materials.Specular)
        sphere1.material.diffuse=color(255,0,0)
    
        sphere2=scene:entity()
        s2=sphere2:add(craft.rigidbody,STATIC)
        s2.restitution=1
        sphere2.position=vec3(0,-5,0)
        sphere2:add(craft.shape.sphere,size)
        sphere2.model = craft.model.icosphere(size,2)
        sphere2.material = craft.material(asset.builtin.Materials.Specular)
        sphere2.material.diffuse=color(0,0,255)
    end
    
    function draw()
        update(DeltaTime)
        scene:draw()    
    end
    
    function update(dt)
        scene:update(dt)
    end
    
Sign In or Register to comment.