Page 1 of 1

love.physics.setMeter() changes behaviour but not the size of drawn bodies

Posted: Sat May 20, 2023 9:00 pm
by mrdarip
:emo: when calling love.physics.setMeter(5) when drawing objects.player.shape = love.physics.newRectangleShape(0, 0, 3, 5) the drawn size is always 3x5 px not mattering what i input as parameter in love.physics.setMeter().
Is this the intended behaviour or am i missing something

Is this correct?
love.physics.setMeter(meters)
love.physics.newRectangleShape(meters, meters, meters,meters)

Should i be using love.graphics.scale()?

Re: love.physics.setMeter() changes behaviour but not the size of drawn bodies

Posted: Sun May 21, 2023 3:51 am
by H.I
s = love.physics.newRectangleShape( body, x, y, width, height, angle )

you are not attaching it to any body, and this is how i use meter:

meter = 10
love.physics.setMeter(meter)

world = love.physics.newWorld(0,100*meter,true)

Re: love.physics.setMeter() changes behaviour but not the size of drawn bodies

Posted: Sun May 21, 2023 8:03 am
by pgimeno
H.I wrote: Sun May 21, 2023 3:51 am s = love.physics.newRectangleShape( body, x, y, width, height, angle )
This is for Löve 0.7.2 and earlier. It doesn't work in any recent version.

Re: love.physics.setMeter() changes behaviour but not the size of drawn bodies

Posted: Sun May 21, 2023 10:20 am
by Rigachupe
setMeter tells the physics of löve2d how much pixels are a meter. So value 20 means each 20pixels is one meter.

The shape functions are based in pixels.

Code: Select all

body = love.physics.newBody(world, 300, 300, "dynamic") -- place the body at pixel coordinates (300,300) or in meter coordinates (10,10)
love.physics.setMeter(10) -- set 10 pixels/meter
body:getPosition() -- returns pixel coordinates (100,100)