Would you recommend to:
- Simplify polygons
- Use external library to handle complicated polygon shapes (that allows for unlimited vertices)
Are you sure? A fixture connects a body with a shape. But a polygon shape can have only 8 vertices (https://love2d.org/wiki/love.physics.newPolygonShape).
I see. I will experiment with that using multiples fixtures.pgimeno wrote: ↑Fri Apr 07, 2023 12:57 pm You only have 1 body. You connect different fixtures to the same body.
Joints, even weld joints, are elastic and cause all kinds of trouble in a situation like this. Shapes attached to the same body via different fixtures, on the other hand, make it behave like a single rigid body.
Code: Select all
player_fixtures = {}
player_fixtures[1]=love.physics.newFixture( player_body, shape1)
player_fixtures[2]=love.physics.newFixture( player_body, shape2)
player_fixtures[3]=love.physics.newFixture( player_body, shape3)
Code: Select all
function createObject(world, params)
local body = love.physics.newBody(world, params.x, params.y, params.type)
local shapes = {}
local fixtures = {}
if type(params.vertices[1]) == 'number' then
shapes[1] = love.physics.newPolygonShape(params.vertices)
else -- we have table with multiple shapes
for i, shape in ipairs(params.vertices) do
shapes[i] = love.physics.newPolygonShape(shape)
end
end
for i, shape in ipairs(shapes) do
fixtures[i] = love.physics.newFixture(body, shape, params.density)
end
return fixtures
end
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 3 guests