Feb22010

# Feb22010

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: UC Santa Cruz Computer Science – Game Design CMPS 20: Game Design Experience 2D Movement Pathﬁnding UC Santa Cruz Computer Science – Game Design Path Following at Constant Speed •  In previous lecture showed path following –  Used Lerp and CatmullRom interpolaDon methods built into Vector2 class –  These methods take an amount •  Problem •  SoluDon •  A number between 0 and 1 indicaDng the percentage distance between the start and end points (a “weight”) –  A given amount can result in diﬀerent perceived speeds, depending on the length of the line –  Given a desired speed in terms of units per clock Dck –  Compute per ­Dck change in amount as follows –  Per ­Dck ­amount = unit ­speed / Vector2.Distance(start, end) •  That is, determine the percentage of the total distance between the points covered by one unit ­speed UC Santa Cruz Computer Science – Game Design Pathﬁnding •  In many games, computer controlled opponents need to move from one place to another in the game world –  If the start and end points are known in advance, and never change, •  •  •  •  Can simply deﬁne a ﬁxed path Computed before the game begins Use path following techniques from previous lecture Most plaXormers do this –  If the start and end points vary, and are not known in advance (or may vary due to changes in game state), •  Have to compute the path to follow while the game is running •  Need to use a pathﬁnding algorithm Video of pathﬁnding problems Pathﬁnding Ar6cle: h9p://www.ai ­blog.net/archives/ 000152.html UC Santa Cruz Computer Science – Game Design Pathﬁnding RepresentaDons •  Waypoints •  NavigaDon Meshes UC Santa Cruz Computer Science – Game Design All Pairs Shortest Path (APSP) •  Assume a labeled directed graph...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online