Chasing npc help?
Posted: Thu Dec 23, 2021 7:05 pm
Im currently trying to make a new custom npc that chases the player around and im not sure what I should do to place in the lua file. I've tried and
Code: Select all
Player.getNearest(x,y)
Code: Select all
function onTick()
-- ...
snpc = ... -- self NPC
-- ...
local p = Player.getNearest(snpc.momentum.x + snpc.momentum.w, snpc.momentum.y + snpc.momentum.h)
if(p)
-- Do some logic with player object "p"
end
-- ...
end