navmeshes · • variation on piano movers problem (a) (b) h ok too short too steep. creating...
TRANSCRIPT
NavMeshesCMSC425.01Spring2019
Stillattables…
Administrivia
• Hw2posted
• Project2outlineready,fulldescriptionsoon
• Practiceexamslinked
• Anychoicesonwhatwedoafterbreak?• Gamedesignbigsubject,lotsoftopicswecanchoosefrom
Project2:CrabSoup,Anyone?
• Goal:Playermustretrievetreasurefromchestonfarisland• Problem:MutatedCrabswillattack
Project2:CrabSoup,Anyone?
• Goal:Playermustretrievetreasurefromchestonfarisland• Problem:MutatedCrabswillattack
• NewUnityelements:• Terrain• NavMesh• AnimatedfiguresforPlayerandCrabs
Yourinstructorplays…
Details
• Part1:Makeittothetreasure!MakeaterrainwithaNavMesh,navigatetotheTreasure,andhavetheCrabschase.Playerhumanoid,Crabsblocks.Winifyoumakeittothetreasurewithoutbeing“crabbed”
• Part2:AnimatePlayerandCrabswithMixamo animations.Addakeythatmustbefoundtoopenchest,returntodocktowin.AddUIgraphictoshowthatkeyispickedup.
• Reach?:Makeitunderwaterwithswimminganimation• Freeto:addelementstomakeitmoreplayable,changethemeifspiritiskept
Today’squestion
HowNPCsmovearound:NavMeshes
Navigationproblems• Navigatingfromplacetoplace• Densecrowdnavigation• Coordinatedteammovement• Pursuit• Movingcomplex/articulatedshape
• Pianomoversproblem(rigid)• Skeleton(articulated)
@UMD:DineshandMing
• Densecrowdsimulations• Howtomovemanyagentsnaturally
• Video
NavigationVersion1:UseamapCreategraphstructureUseDijkstra'salgorithm
Shortestpath
Assumption:Worldisrigid,limitedlanesformovement
Whatis"shortest"path?
• Distance?
Whatis"shortest"path?
• Distance?• Speed?• Energycost?• Exposuretoenemy?
• Hexmap• 6directions• Terraintypes=>speedcosts
NavigationVersion2:OpenTerrain
• Mixofobstaclesandopenspaces:"freespacegeometry"• Moreoptionsfordirection• Howpickpath?
Howpickbestpath?
• Shortestmaynotbemostnatural(dashedline)• Needwaytodetectnaturalcorridors
Solution1:Waypointroadmap
• Preprocessspaceintographofwaypoints• Placewaypointsalongnaturalcorridors
Solution1:Waypointroadmap
• Preprocessspaceintographofwaypoints• Placewaypointsalongnaturalcorridors• Drawbacks• Couldneedlotsofwaypoints• Hardertoplanforcoordinatedteammovement
Solution2:Navmesh
• Preprocessspaceintomeshoffreeareasaspolygons• Planmovementbetweenpolygons• Betweenedges• Betweencenters
• Multiplelevelgraphsearch• Firstbetweenregions• Thenpickentryandexitpoints
Navmeshes canbe
• Labeledwithdifferentterraintypes• Setwith"gates"
• 2Dmanifoldswhicharetopologicallycomplex(eg,non-planar)
UsingNavmesh
• Insideregionusedirectpath
• Regions(andsubregions)canbelabeledwithdifferentterraintypesandcosts
CreatingNavmeshes fromterrain
• Step1:Findwalkablesurfaces• Aslargepolygon"map"
• Step2:Simplifyboundaries• Simplifypolygon"map"
• Step3:Triangulate"map"• Coverwithsetoftriangles
CreatingNavmeshes fromterrain
• Step1:Findwalkablesurfacesbasedonagentheight,width,slopeability
• Variationonpianomoversproblem
(a) (b)
h
too shortok
too steep
CreatingNavmeshes fromterrain
• Step2:Simplifyboundaries• Simplifypolygon"map"
• Recursiverefinementofstraightline
CreatingNavmeshes fromterrain
• Step3:Triangulate"map"• Coverwithsetoftriangles
• Bridgeholes• Cutears(!)
(a) (b)
v0
v1v2
vi�1
vi+1
viear
(c)
vn
chord
chordbridging
UseNavmesh:findpath
• Discretizebyaddingpoints• Findshortestpath
(b) (c)(a)
UseNavmesh:refine
• Smoothandcleanpath
(a) (b) (c)
t
s
t
s
t
s
Navmeshes inUnity
• Createterrain• Terraineditor
• Setagentnavigationproperties• Height,widthofagent• Slopecapability
• BakeNavmesh• Findsnavigableregions• Createsmesh
Agentproperties
• Radius,Height• Stepheight• Maxslope
• Canhavemultipleagenttypes
Offmeshlinks
Question
• Howdoesthisallrelatetocolliders?
Readings
• LookatUnitymanualandtutorials• Terrain• https://docs.unity3d.com/Manual/terrain-UsingTerrains.html
• NavMesh• https://unity3d.com/learn/tutorials/topics/navigation/navmesh-agent• https://docs.unity3d.com/Manual/nav-BuildingNavMesh.html
• Animation• https://unity3d.com/learn/tutorials/topics/animation/animate-anything-mecanim• https://unity3d.com/learn/tutorials/s/animation