diff --git a/lib/character/logic.lua b/lib/character/logic.lua index 2ac7ecc..dcdee36 100644 --- a/lib/character/logic.lua +++ b/lib/character/logic.lua @@ -24,7 +24,15 @@ end function logic:followPath(path) if path:is_empty() then return end self.mapLogic.path = path; - self:runTo(path:peek_front()) + ---@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 diff --git a/lib/selector.lua b/lib/selector.lua index c9efff8..8784b25 100644 --- a/lib/selector.lua +++ b/lib/selector.lua @@ -30,11 +30,6 @@ function selector:update(dt) if not characterId and self.id then -- временная обработка события "побежать к точке" local char = Tree.level.characters[self.id] local charPos = char.logic.mapLogic.position - if mousePosition.x < charPos.x then - char.graphics.animation.side = LEFT - elseif mousePosition.x > charPos.x then - char.graphics.animation.side = RIGHT - end local path = (require "lib.pathfinder")(charPos, mousePosition) path:pop_front() print("Following path: ")