navmeshes · • variation on piano movers problem (a) (b) h ok too short too steep. creating...

31
NavMeshes CMSC425.01 Spring 2019 Still at tables …

Upload: others

Post on 04-Aug-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •

NavMeshesCMSC425.01Spring2019

Stillattables…

Page 2: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •

Administrivia

• Hw2posted

• Project2outlineready,fulldescriptionsoon

• Practiceexamslinked

• Anychoicesonwhatwedoafterbreak?• Gamedesignbigsubject,lotsoftopicswecanchoosefrom

Page 3: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •

Project2:CrabSoup,Anyone?

• Goal:Playermustretrievetreasurefromchestonfarisland• Problem:MutatedCrabswillattack

Page 4: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •

Project2:CrabSoup,Anyone?

• Goal:Playermustretrievetreasurefromchestonfarisland• Problem:MutatedCrabswillattack

• NewUnityelements:• Terrain• NavMesh• AnimatedfiguresforPlayerandCrabs

Page 5: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •
Page 6: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •

Yourinstructorplays…

Page 7: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •

Details

• Part1:Makeittothetreasure!MakeaterrainwithaNavMesh,navigatetotheTreasure,andhavetheCrabschase.Playerhumanoid,Crabsblocks.Winifyoumakeittothetreasurewithoutbeing“crabbed”

• Part2:AnimatePlayerandCrabswithMixamo animations.Addakeythatmustbefoundtoopenchest,returntodocktowin.AddUIgraphictoshowthatkeyispickedup.

• Reach?:Makeitunderwaterwithswimminganimation• Freeto:addelementstomakeitmoreplayable,changethemeifspiritiskept

Page 8: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •

Today’squestion

HowNPCsmovearound:NavMeshes

Page 9: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •

Navigationproblems• Navigatingfromplacetoplace• Densecrowdnavigation• Coordinatedteammovement• Pursuit• Movingcomplex/articulatedshape

• Pianomoversproblem(rigid)• Skeleton(articulated)

Page 10: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •

@UMD:DineshandMing

• Densecrowdsimulations• Howtomovemanyagentsnaturally

• Video

Page 11: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •

NavigationVersion1:UseamapCreategraphstructureUseDijkstra'salgorithm

Shortestpath

Assumption:Worldisrigid,limitedlanesformovement

Page 12: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •

Whatis"shortest"path?

• Distance?

Page 13: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •

Whatis"shortest"path?

• Distance?• Speed?• Energycost?• Exposuretoenemy?

• Hexmap• 6directions• Terraintypes=>speedcosts

Page 14: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •

NavigationVersion2:OpenTerrain

• Mixofobstaclesandopenspaces:"freespacegeometry"• Moreoptionsfordirection• Howpickpath?

Page 15: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •

Howpickbestpath?

• Shortestmaynotbemostnatural(dashedline)• Needwaytodetectnaturalcorridors

Page 16: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •

Solution1:Waypointroadmap

• Preprocessspaceintographofwaypoints• Placewaypointsalongnaturalcorridors

Page 17: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •

Solution1:Waypointroadmap

• Preprocessspaceintographofwaypoints• Placewaypointsalongnaturalcorridors• Drawbacks• Couldneedlotsofwaypoints• Hardertoplanforcoordinatedteammovement

Page 18: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •

Solution2:Navmesh

• Preprocessspaceintomeshoffreeareasaspolygons• Planmovementbetweenpolygons• Betweenedges• Betweencenters

• Multiplelevelgraphsearch• Firstbetweenregions• Thenpickentryandexitpoints

Page 19: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •

Navmeshes canbe

• Labeledwithdifferentterraintypes• Setwith"gates"

• 2Dmanifoldswhicharetopologicallycomplex(eg,non-planar)

Page 20: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •

UsingNavmesh

• Insideregionusedirectpath

• Regions(andsubregions)canbelabeledwithdifferentterraintypesandcosts

Page 21: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •

CreatingNavmeshes fromterrain

• Step1:Findwalkablesurfaces• Aslargepolygon"map"

• Step2:Simplifyboundaries• Simplifypolygon"map"

• Step3:Triangulate"map"• Coverwithsetoftriangles

Page 22: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •

CreatingNavmeshes fromterrain

• Step1:Findwalkablesurfacesbasedonagentheight,width,slopeability

• Variationonpianomoversproblem

(a) (b)

h

too shortok

too steep

Page 23: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •

CreatingNavmeshes fromterrain

• Step2:Simplifyboundaries• Simplifypolygon"map"

• Recursiverefinementofstraightline

Page 24: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •

CreatingNavmeshes fromterrain

• Step3:Triangulate"map"• Coverwithsetoftriangles

• Bridgeholes• Cutears(!)

(a) (b)

v0

v1v2

vi�1

vi+1

viear

(c)

vn

chord

chordbridging

Page 25: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •

UseNavmesh:findpath

• Discretizebyaddingpoints• Findshortestpath

(b) (c)(a)

Page 26: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •

UseNavmesh:refine

• Smoothandcleanpath

(a) (b) (c)

t

s

t

s

t

s

Page 27: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •

Navmeshes inUnity

• Createterrain• Terraineditor

• Setagentnavigationproperties• Height,widthofagent• Slopecapability

• BakeNavmesh• Findsnavigableregions• Createsmesh

Page 28: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •

Agentproperties

• Radius,Height• Stepheight• Maxslope

• Canhavemultipleagenttypes

Page 29: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •

Offmeshlinks

Page 30: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •

Question

• Howdoesthisallrelatetocolliders?

Page 31: NavMeshes · • Variation on piano movers problem (a) (b) h ok too short too steep. Creating Navmeshesfrom terrain • Step 2: Simplify boundaries • Simplify polygon "map" •

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