Page 1 of 1

Chasing npc help?

Posted: Thu Dec 23, 2021 7:05 pm
by Hammerless Penguin
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

Code: Select all

Player.getNearest(x,y)
and

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

Re: Chasing npc help?

Posted: Tue Dec 28, 2021 6:59 am
by Marioman2007
If you want the NPC to chase the player like a chasing koopa, then you could set isflying to true.

Re: Chasing npc help?

Posted: Fri Apr 15, 2022 8:10 pm
by NoobSimBot
Marioman2007 wrote:
Tue Dec 28, 2021 6:59 am
If you want the NPC to chase the player like a chasing koopa, then you could set isflying to true.
I also have an NPC whose "isFlying" is set to True. Only problem is, despite having the Paratroopa algorithm in the .ini file of the NPC, it still
resorts to chasing the player and ignores the other options (Jump, Hover Left/Right, etc.)

Re: Chasing npc help?

Posted: Sat Apr 16, 2022 5:57 am
by Marioman2007
NoobSimBot wrote:
Fri Apr 15, 2022 8:10 pm
Marioman2007 wrote:
Tue Dec 28, 2021 6:59 am
If you want the NPC to chase the player like a chasing koopa, then you could set isflying to true.
I also have an NPC whose "isFlying" is set to True. Only problem is, despite having the Paratroopa algorithm in the .ini file of the NPC, it still
resorts to chasing the player and ignores the other options (Jump, Hover Left/Right, etc.)
Because ini files only affect the editor.

Re: Chasing npc help?

Posted: Sat Apr 16, 2022 12:15 pm
by NoobSimBot
Because ini files only affect the editor.
This one I learned it myself. The thing is, I want this NPC to actually care about the choice of algorithm in the editor, and behave as told.
I know I should look around in the .lua file of the NPC, but I don't know how to just make it so it acts like the other Parakoopas in
the editor.

Just trying to learn lua language is a really huge chore for me, hence my username.