Posts: 244
Threads: 25
Joined: Feb 2014
How do you add avoidance area to a mesh?
Posts: 6,540
Threads: 67
Joined: Nov 2013
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.
Posts: 244
Threads: 25
Joined: Feb 2014
Oh i was under the impression that you can add these blue box.
Posts: 122
Threads: 37
Joined: Jan 2014
(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.
Posts: 878
Threads: 5
Joined: Feb 2011
Reputation:
5
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,e = next(el)
local dirty = false
local obst = {}
local count = 1
while (i~=nil and e ~= nil) do
if (e.targetable) then
local pos = deepcopy(e.pos);
pos.r = 15.0
pos.y = pos.y
obst[count] = pos
--d("added " .. e.name .. " id=" .. e.id)
count = count +1
end
i,e = 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.
...................................
Yeah, well. The Dude abides.