mirror of
https://github.com/ElCeejo/creatura.git
synced 2025-07-12 09:32:23 -04:00
Pathfinding Fixes
mob_meta.get_node_height: Moved to pathfinding, and made public (creatura.get_node_height). Now uses collision box rather than node box, if available, unless flag specifies not to. Fix for getting node height for nodes with connected node boxes pathfinding.get_ground_level: We now have one copy between pathfinding and mob_meta. Can check a larger range of nodes at different heights. Takes into account node height of both target node, and the height of the node we're coming from. pathfinding.get_neighbors: Get maximum distance mob can travel up/down from mob stepheight. Improved checking diagonals are clear. Improved checking vertical clearance, takes into account height of current and target node. Vertical clearance can cope with nodes that have a different collision and node boxes, like snow. Vertical clearance has a tiny height adjustment so a 2 node heigh entity can fit through a 2 node gap. Fixed bug where it was assumed a node was reachable if it's the end goal. methods.movement_theta_pathfind and movement_pathfind: Fixed bug that raised goal pos by 0.5 nodes.
This commit is contained in:
parent
23c61e0751
commit
35069011d6
3 changed files with 185 additions and 231 deletions
|
@ -166,7 +166,6 @@ end
|
|||
|
||||
local function movement_theta_pathfind(self, pos2, speed)
|
||||
local pos = self.object:get_pos()
|
||||
local goal = pos2
|
||||
self._path = self._path or {}
|
||||
local temp_goal = self._movement_data.temp_goal
|
||||
if not temp_goal
|
||||
|
@ -182,7 +181,6 @@ local function movement_theta_pathfind(self, pos2, speed)
|
|||
table.remove(self._path, 1)
|
||||
end
|
||||
end
|
||||
goal.y = pos.y + 0.5
|
||||
local dir = vector.direction(self.object:get_pos(), pos2)
|
||||
local tyaw = minetest.dir_to_yaw(dir)
|
||||
local turn_rate = self.turn_rate or 10
|
||||
|
@ -201,7 +199,7 @@ local function movement_theta_pathfind(self, pos2, speed)
|
|||
self:animate("walk")
|
||||
self:set_gravity(-9.8)
|
||||
self:set_forward_velocity(speed or 2)
|
||||
if self:pos_in_box(goal) then
|
||||
if self:pos_in_box(pos2) then
|
||||
self:halt()
|
||||
end
|
||||
end
|
||||
|
@ -210,7 +208,6 @@ creatura.register_movement_method("creatura:theta_pathfind", movement_theta_path
|
|||
|
||||
local function movement_pathfind(self, pos2, speed)
|
||||
local pos = self.object:get_pos()
|
||||
local goal = pos2
|
||||
local temp_goal = self._movement_data.temp_goal
|
||||
self._path = self._path or {}
|
||||
if (not temp_goal
|
||||
|
@ -227,7 +224,6 @@ local function movement_pathfind(self, pos2, speed)
|
|||
table.remove(self._path, 1)
|
||||
end
|
||||
end
|
||||
goal.y = pos.y + 0.5
|
||||
local dir = vector.direction(self.object:get_pos(), pos2)
|
||||
local tyaw = minetest.dir_to_yaw(dir)
|
||||
local turn_rate = self.turn_rate or 10
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue