Page 1 of 1

dt is a nil value?

Posted: Fri Jan 01, 2016 1:09 am
by EportV
im trying to make a player movement system, however it keeps telling me that dt is a nil value... help?


function player.move(dt)
local x, y = nil, nil
if love.keyboard.isDown("up") then
y = player.y - player.speed * dt
elseif love.keyboard.isDown("down") then
y = player.y + player.speed * dt
end

if love.keyboard.isDown("left") then
x = player.x - player.speed * dt
elseif love.keyboard.isDown("right") then
x = player.x + player.speed * dt
end

end

Re: dt is a nil value?

Posted: Fri Jan 01, 2016 1:39 am
by veethree
Are you calling "player.move()" inside love.update? if so are you calling it with dt as the argument? If you're not calling it within love.update you can put "local dt = love.timer.getDelta()" at the top of player.move.

Re: dt is a nil value?

Posted: Fri Jan 01, 2016 1:53 am
by EportV
@veethree

wont work still :(

Re: dt is a nil value?

Posted: Fri Jan 01, 2016 3:05 am
by Beelz
Without knowing more, its hard to help you... Could you post a .love so we can take a look?