From 8c1166216c17e09712597207c4d13326f78059b1 Mon Sep 17 00:00:00 2001 From: PeaAshMeter Date: Wed, 3 Sep 2025 00:42:40 +0300 Subject: [PATCH] fix character rotation while moving --- lib/character/logic.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/character/logic.lua b/lib/character/logic.lua index dcdee36..0eb966f 100644 --- a/lib/character/logic.lua +++ b/lib/character/logic.lua @@ -26,12 +26,6 @@ function logic:followPath(path) self.mapLogic.path = path; ---@type Vec3 local nextCell = path:peek_front() - local charPos = self.mapLogic.position - if nextCell.x < charPos.x then - Tree.level.characters[self.id].graphics.animation.side = LEFT - elseif nextCell.x > charPos.x then - Tree.level.characters[self.id].graphics.animation.side = RIGHT - end self:runTo(nextCell) path:pop_front() end @@ -41,6 +35,12 @@ function logic:runTo(target) self.mapLogic.t0 = love.timer.getTime() self.state = "run" self.mapLogic.runTarget = target + local charPos = self.mapLogic.position + if target.x < charPos.x then + Tree.level.characters[self.id].graphics.animation.side = LEFT + elseif target.x > charPos.x then + Tree.level.characters[self.id].graphics.animation.side = RIGHT + end end function logic:update(dt)