Page 1 of 1

npc walks in a direction unintentionally

Posted: Fri Mar 05, 2021 5:48 pm
by Gabriel_2004
Hello, the custom npc I'm doing has a small problem that I don't know how to solve, it was supposed to move back and forth, without having to change the v.direction (similar to birdo) using a timer as a reference, but even though I put the code below, it only walks in one direction, if someone could help me I would be grateful
Spoiler: show
if player.x < v.x then
v.direction = -1
elseif player.x > v.x then
v.direction = 1
end

if data.shoottimer > 80 then
v.speedX = v.direction * 0.65
elseif data.shoottimer < 80 then
v.speedX = -v.direction * 0.65
end

Re: npc walks in a direction unintentionally

Posted: Sat Mar 06, 2021 2:55 pm
by MrDoubleA
NPC's will always look in the direction that they're moving in, unless you set "staticdirection = true," along with all the other config settings.