SetSweptCollisionMode

This function sets the swept collision mode of an entity. Entities with swept collision enabled will have more accurate collisions that are more computationally expensive to process. Use this for small and thin objects if you have problems with them going through other entities.

Syntax

Parameters

Example

--Create a window
window = Window:Create()
context = Context:Create(window)
world = World:Create()
local camera = Camera:Create()
camera:SetRotation(35,0,0)
camera:Move(0,0,-8)
local light = DirectionalLight:Create()
light:SetRotation(35,35,0)

--Create the ground
local ground = Model:Box(10,0.1,10)
ground:SetColor(0.0,1.0,0.0)

--Create a shape
local shape = Shape:Box(0,0,0, 0,0,0, 10,0.1,10)
ground:SetShape(shape)
shape:Release()

--Create a model
entity1 = Model:Box()
entity1:SetScale(1,0.1,4)
entity1:SetColor(0.0,0.0,1.0)
entity1:SetPosition(-2,5,0)
entity1:SetMass(1)
entity1:AddForce(0,-1000,0)

--Create a shape
shape = Shape:Box()
entity1:SetShape(shape)
shape:Release()

--Create a second model
entity2 = entity1:Instance()
entity2:SetPosition(2,5,0)
entity2:SetSweptCollisionMode(true)
entity2:AddForce(0,-1000,0)

while true do
if window:Closed() or window:KeyHit(Key.Escape) then return false end

Time:Update()
world:Update()
world:Render()

context:SetBlendMode(Blend.Alpha)
context:DrawText("entity1 swept collision mode: "..tostring(entity1:GetSweptCollisionMode()),2,2)
context:DrawText("entity2 swept collision mode: "..tostring(entity2:GetSweptCollisionMode()),2,22)

context:Sync()
end