I'm learning love2d and I've been tinkering with some things. There is one thing that confuses me, namely, it seems like physics properties like velocity (but also forces and impulses) have different effects when applied to entities before after the first `world:update`. Is there a reason for this? This makes it hard to set proper "initial state" for the game, as one has to wait until the world executes a single update, and then apply physics properties to objects.
Consider this example:
Code: Select all
-- main.lua
local world = love.physics.newWorld(0, 0)
local entity = {}
entity.body = love.physics.newBody(world, 200, 200, 'dynamic')
entity.body:setMass(32)
-- entity.body:setLinearVelocity(500, 0)
entity.shape = love.physics.newCircleShape(0, 0, 10)
entity.fixture = love.physics.newFixture(entity.body, entity.shape)
love.draw = function()
print(entity.body:getLinearVelocity())
local ball_x, ball_y = entity.body:getWorldCenter()
love.graphics.circle('fill', ball_x, ball_y, entity.shape:getRadius())
end
local applied = false
love.update = function(dt)
world:update(dt)
-- if not applied then
-- entity.body:setLinearVelocity(500, 0)
-- applied = true
-- end
end