Page 1 of 1

Cliffturn and change direction don 't work

Posted: Sat Feb 20, 2021 2:17 pm
by Gabriel_2004
Hello, I'm new to this forum and it's my first time messing with it (so much that my English is not the best), I'm kind of having problems with a code I'm making and would be grateful if they told me what I did wrong, it was supposed to this npc i'm creating, when colliding with a block or another npc change the direction, but it keeps walking even if it has already collided with a block and he was also supposed to change direction when a cliff appeared, but even with the "cliffturn = true" option, he still falls off cliffs
Spoiler: show

v.speedX = 1 * v.direction
if v.direction == -1 then
v.animationFrame = math.floor(lunatime.tick() / 4) % 2
else
v.animationFrame = (math.floor(lunatime.tick() / 4) % 2) + 2
end

if v.collidesBlockLeft or v.collidesBlockRight then
v.speedX = -1 * v.direction
if v.direction == 1 then
v.animationFrame = (math.floor(lunatime.tick() / 4) % 2) + 2
else
v.animationFrame = math.floor(lunatime.tick() / 4) % 2
end
end

Re: Cliffturn and change direction don 't work

Posted: Sun Feb 21, 2021 7:21 am
by MrDoubleA
NPC's automatically turn around when they hit a block. You don't need to do that.

Re: Cliffturn and change direction don 't work

Posted: Sun Feb 21, 2021 11:42 am
by Gabriel_2004
MrDoubleA wrote:
Sun Feb 21, 2021 7:21 am
NPC's automatically turn around when they hit a block. You don't need to do that.
OK, thanks