Cliffturn and change direction don 't work

Post here for help and support regarding LunaLua and SMBX2's libraries and features.

Moderator: Userbase Moderators

Gabriel_2004
Cheep-Cheep
Cheep-Cheep
Posts: 10
Joined: Sat Feb 20, 2021 11:04 am
Pronouns: he/him

Cliffturn and change direction don 't work

Postby Gabriel_2004 » Sat Feb 20, 2021 2:17 pm

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

MrDoubleA
Ripper II
Ripper II
Posts: 394
Joined: Mon Aug 20, 2018 7:02 am
Flair: How much munchers?

Re: Cliffturn and change direction don 't work

Postby MrDoubleA » Sun Feb 21, 2021 7:21 am

NPC's automatically turn around when they hit a block. You don't need to do that.

Gabriel_2004
Cheep-Cheep
Cheep-Cheep
Posts: 10
Joined: Sat Feb 20, 2021 11:04 am
Pronouns: he/him

Re: Cliffturn and change direction don 't work

Postby Gabriel_2004 » Sun Feb 21, 2021 11:42 am

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


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 2 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari