R3d.Fixture:setMaterial
From GiderosMobile
Available since: Gideros 2019.10
Class: R3d.Fixture
Description
Sets the fixture material (bounciness, frictionCoefficient, rollingResistance).
r3d.Fixture:setMaterial(material)
Parameters
material: (table) the fixture material table
Example
-- the body
view.body = xworld:createBody(view:getMatrix())
local shape = r3d.SphereShape.new(params.sizex) -- radius
local fixture = view.body:createFixture(shape, nil, params.mass)
-- materials default: bounciness=0.5, frictionCoefficient=0.3, rollingResistance=0
local mat = fixture:getMaterial()
mat.bounciness = 0.1
mat.frictionCoefficient = 0.5
mat.rollingResistance = 0.1 -- 0 = no resistance, 1 = max resistance
fixture:setMaterial(mat)