MMOMinion

Full Version: Avoidance area
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How do you add avoidance area to a mesh?
what do you mena by avoidcance area? as in you do not want the bot to ever run into this area? if so just delete the mesh triangles from that section.
[Image: wZQwE9E.jpg]

Oh i was under the impression that you can add these blue box.
(02-12-2014, 11:54 PM)jackie1234 Wrote: [ -> ]what do you mena by avoidcance area? as in you do not want the bot to ever run into this area? if so just delete the mesh triangles from that section.

Is there a more efficient way of deleting mesh triangles? One by one is slow.
Its not in the wiki yet and its still beta but here is some code to use avoidance.
PHP Code:
function Dev.TestObst()
  
local el EntityList("attackable,aggressive,notincombat,maxdistance=500,fateid=0")
  
local i,next(el)
  
local dirty false
  local obst 
= {}
  
local count 1
  
while (i~=nil and ~= nil) do
    if (
e.targetablethen
      local pos 
deepcopy(e.pos);
      
pos.15.0
      pos
.pos.y
      obst
[count] = pos
      
--d("added " .. e.name .. " id=" .. e.id)
      
count count +1
    end
    i
,next(el,i
  
end
  NavigationManager
:SetAvoidanceAreas(obst)
end 

There are two different kinds of obstacles, hard and soft. The above code places soft obstacles by increasing the costs of the polygons that potential threads are on. So the bot will walk through them if going another way costs more.
You can turn those into hard obstacles by replacing the NavigationManager:SetAvoidanceAreas() call with NavigationManager:AddNavObstacles(). this will remove the areas from the navmesh completely. This may render the mesh unusable until they removed again. Both obstacles are only temporary, so they are not saved with the mesh. Every call to either add function removes the previously set areas of that kind. if you want to clear the obstacles without setting new one, use NavigationManager:ClearNavObstacles() and NavigationManager:ClearAvoidanceAreas().
If you add obstacles while the bot is navigating, it will recalculate its path on-the-fly. If you use random paths that may have some undesired effects, like zick-zacking.
Both obstacle kinds are visible if you turn on "Show Navmesh". Soft obstacles recolor the the polygons directly and hard obstacles are 3d cylinders.