Waypoints.htm 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935
  1. <html xmlns:MSHelp="http://msdn.microsoft.com/mshelp" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:xanx="http://schemas.microsoft.com/developer/xanx/2005"><head><META http-equiv="Content-Type" content="text/html; charset=utf-8"><META NAME="save" CONTENT="history"><title>Waypoint Navigation</title>
  2. <style><!--
  3. /***********************************************************
  4. * SCRIPT-SUPPORTING STYLES
  5. ***********************************************************/
  6. /* Defines the userData cache persistence mechanism. */
  7. .userDataStyle
  8. {
  9. behavior: url(#default#userData);
  10. }
  11. /* Used to save the scroll bar position when navigating away from a page. */
  12. div.saveHistory
  13. {
  14. behavior: url(#default#saveHistory);
  15. }
  16. /* Formats the expand/collapse images for all collapsible regions. */
  17. img.toggle
  18. {
  19. border: 0;
  20. margin-right: 5;
  21. }
  22. /* Formats the Language filter drop-down image. */
  23. img#languageFilterImage
  24. {
  25. border: 0;
  26. margin-left: 0;
  27. vertical-align: middle;
  28. }
  29. /* Formats the Members Options filter drop-down image. */
  30. img#membersOptionsFilterImage
  31. {
  32. border: 0;
  33. margin-left: 0;
  34. vertical-align: middle;
  35. }
  36. /* Formats the Collapse All/Expand All images. */
  37. img#toggleAllImage
  38. {
  39. margin-left: 0;
  40. vertical-align: middle;
  41. }
  42. /* Supports XLinks */
  43. MSHelp\:link
  44. {
  45. text-decoration: underline;
  46. color: #0000ff;
  47. hoverColor: #3366ff;
  48. filterString: ;
  49. }
  50. body
  51. {
  52. background: #FFFFFF;
  53. color: #000000;
  54. font-family: Verdana;
  55. font-size: medium;
  56. font-style: normal;
  57. font-weight: normal;
  58. margin-top: 0;
  59. margin-bottom: 0;
  60. margin-left: 0;
  61. margin-right: 0;
  62. width: 100%;
  63. /*font-size: 110%;*/
  64. }
  65. div.section
  66. {
  67. margin-left: 15px;
  68. }
  69. div.hxnx5
  70. {
  71. margin-left: 1.5em;
  72. }
  73. /* Font for all headings */
  74. h1, h2, h3, h4, h5, h6
  75. {
  76. font-family: Verdana, Arial, Helvetica, sans-serif;
  77. margin-top: 18;
  78. margin-bottom: 8;
  79. font-weight: bold;
  80. }
  81. h1
  82. {
  83. font-size: 130%;
  84. color: #003399;
  85. }
  86. div#scrollyes h1 /* Changes font size for full-scrolling topic */
  87. {
  88. font-size: 150%;
  89. }
  90. h2
  91. {
  92. font-size: 125%;
  93. }
  94. h3
  95. {
  96. font-size: 115%;
  97. margin-top: 9;
  98. margin-bottom: 4;
  99. }
  100. h4
  101. {
  102. font-size: 115%;
  103. margin-top: 9;
  104. margin-bottom: 4;
  105. }
  106. h5
  107. {
  108. font-size: 100%;
  109. margin-top: 9;
  110. margin-bottom: 4;
  111. }
  112. h6
  113. {
  114. font-size: 100%;
  115. margin-top: 9;
  116. margin-bottom: 4;
  117. }
  118. ul p, ol p, dl p
  119. {
  120. margin-left: 0em;
  121. }
  122. p
  123. {
  124. margin-top: .6em;
  125. margin-bottom: .6em;
  126. }
  127. td p
  128. {
  129. margin-top: 0.0em;
  130. margin-bottom: 0.6em;
  131. }
  132. dd p
  133. {
  134. margin-top: 0.0em;
  135. margin-bottom: 0.6em;
  136. }
  137. .image
  138. {
  139. text-align: center;
  140. }
  141. dl
  142. {
  143. margin-top: 0em;
  144. margin-bottom: 1.3em;
  145. }
  146. dd
  147. {
  148. margin-bottom: 0em;
  149. margin-left: 0;
  150. }
  151. dl.glossary dd
  152. {
  153. margin-bottom: 0em;
  154. margin-left: 1.5em;
  155. }
  156. dt
  157. {
  158. margin-top: .6em;
  159. margin-bottom: 1;
  160. }
  161. ul, ol
  162. {
  163. margin-top: 0.6em;
  164. margin-bottom: 0.6em;
  165. }
  166. ol
  167. {
  168. margin-left: 2.5em;
  169. }
  170. ul
  171. {
  172. margin-left: 1.9em;
  173. }
  174. li
  175. {
  176. margin-bottom: 0.4em;
  177. }
  178. ul ol, ol ol
  179. {
  180. list-style-type: lower-alpha;
  181. }
  182. pre
  183. {
  184. margin-top: .6em;
  185. margin-bottom: .6em;
  186. }
  187. pre
  188. {
  189. font: 105% Lucida, mono;
  190. color: #000066;
  191. }
  192. code
  193. {
  194. font-family: Monospace, Courier New, Courier;
  195. font-size: 105%;
  196. color: #000066;
  197. }
  198. table.userdata td
  199. {
  200. background: #ffffff;
  201. background-color: #F5F5F5;
  202. border-color: #ffffff;
  203. border: none;
  204. }
  205. table.clsWarning
  206. {
  207. background: #ffffff;
  208. padding: 0px;
  209. margin: 0px;
  210. border: none;
  211. }
  212. table.clsWarning td
  213. {
  214. padding: 0px;
  215. margin: 0px;
  216. background: #ffffff;
  217. vertical-align: middle;
  218. font-size: 70%;
  219. }
  220. div#mainSection table
  221. {
  222. width: 98%;
  223. background: #ffffff;
  224. margin-top: 5px;
  225. margin-bottom: 5px;
  226. }
  227. div#mainSection table th
  228. {
  229. padding: 5px 6px;
  230. background: #EFEFF7;
  231. text-align: left;
  232. font-size: 70%;
  233. vertical-align: bottom;
  234. border-bottom: 1px solid #C8CDDE;
  235. }
  236. div#mainSection table td
  237. {
  238. padding: 5px 5px;
  239. background: #F7F7FF;
  240. vertical-align: top;
  241. font-size: 70%;
  242. border-bottom: 1px solid #D5D5D3;
  243. }
  244. div#syntaxCodeBlocks table th
  245. {
  246. padding: 1px 6px;
  247. color: #000066;
  248. }
  249. div#syntaxCodeBlocks table td
  250. {
  251. padding: 1px 5px;
  252. }
  253. /* Applies to the running header text in the first row of the upper table in the
  254. non-scrolling header region. */
  255. span#runningHeaderText
  256. {
  257. color: #003399;
  258. font-size: 90%;
  259. padding-left: 13;
  260. }
  261. /* Applies to the topic title in the second row of the upper table in the
  262. non-scrolling header region. */
  263. span#nsrTitle
  264. {
  265. color: #003399;
  266. font-size: 120%;
  267. font-weight: 600;
  268. padding-left: 13;
  269. }
  270. /* Applies to everything below the non-scrolling header region. */
  271. div#mainSection
  272. {
  273. font-size: 70%;
  274. width: 100%;
  275. }
  276. /* Applies to everything below the non-scrolling header region, minus the footer. */
  277. div#mainBody
  278. {
  279. font-size: 90%;
  280. margin-left: 15;
  281. margin-top: 10;
  282. padding-bottom: 20;
  283. }
  284. /* Adds right padding for all blocks in mainBody */
  285. div#mainBody p, div#mainBody ol, div#mainBody ul, div#mainBody dl
  286. {
  287. padding-right: 5;
  288. }
  289. div#mainBody div.alert, div#mainBody div.code, div#mainBody div.tableSection
  290. {
  291. width:98.9%;
  292. }
  293. div.alert p, div.code p
  294. {
  295. margin-top:5;
  296. margin-bottom:8;
  297. }
  298. /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Begin Note Styles - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
  299. div#mainSection div.alert table
  300. {
  301. border: 0;
  302. }
  303. div#mainSection div.alert table th
  304. {
  305. padding-top: 0;
  306. padding-bottom: 0;
  307. padding-left: 5;
  308. padding-right: 5;
  309. }
  310. div#mainSection div.alert table td
  311. {
  312. padding-left: 5;
  313. padding-right: 5;
  314. }
  315. img.note
  316. {
  317. border: 0;
  318. margin-left: 0;
  319. margin-right: 3;
  320. }
  321. /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - End Note Styles - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
  322. /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Begin Non-scrolling Header Region Styles - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
  323. /* Applies to the entire non-scrolling header region. */
  324. div#header
  325. {
  326. background-color: #D4DFFF;
  327. padding-top: 0;
  328. padding-bottom: 0;
  329. padding-left: 0;
  330. padding-right: 0;
  331. width: 100%;
  332. }
  333. /* Applies to both tables in the non-scrolling header region. */
  334. div#header table
  335. {
  336. margin-top: 0;
  337. margin-bottom: 0;
  338. border-bottom-color: #C8CDDE;
  339. border-bottom-style: solid;
  340. border-bottom-width: 1;
  341. background: #D4DFFF;
  342. width: 100%;
  343. }
  344. /* Applies to cells in both tables in the non-scrolling header region. */
  345. div#header table td
  346. {
  347. color: #0000FF;
  348. font-size: 70%;
  349. padding-right: 20;
  350. padding-top: 1;
  351. padding-bottom: 1;
  352. border: none;
  353. background: #D4DFFF;
  354. }
  355. /* Applies to the last row in the upper table of the non-scrolling header region. Text
  356. in this row includes See Also, Constructors, Methods, and Properties. */
  357. div#header table tr#headerTableRow3 td
  358. {
  359. padding-bottom: 2;
  360. padding-top: 5;
  361. padding-left: 15;
  362. }
  363. /* Applies to the lower table in the non-scrolling header region. Text in this table
  364. includes Collapse All/Expand All, Language Filter, and Members Options. */
  365. div#header table#bottomTable
  366. {
  367. border-top-color: #FFFFFF;
  368. border-top-style: solid;
  369. border-top-width: 1;
  370. text-align: left;
  371. padding-left: 15;
  372. }
  373. blockquote
  374. {
  375. margin-left: 3.8em;
  376. margin-right: 3.8em;
  377. margin-top: .6em;
  378. margin-bottom: .6em;
  379. }
  380. sup
  381. {
  382. text-decoration: none;
  383. font-size: smaller;
  384. }
  385. a:link
  386. {
  387. color: #0000FF;
  388. /* font-weight: bold */
  389. }
  390. a:visited
  391. {
  392. color: #0000AA;
  393. /* font-weight: bold */
  394. }
  395. a:hover
  396. {
  397. color: #3366FF;
  398. /* font-weight: bold */
  399. }
  400. .label
  401. {
  402. font-weight: bold;
  403. margin-top: 1em;
  404. margin-left: -26px;
  405. }
  406. .tl
  407. {
  408. margin-bottom: .75em;
  409. }
  410. .atl
  411. {
  412. padding-left: 1.5em;
  413. padding-bottom: .75em;
  414. }
  415. .cfe
  416. {
  417. font-weight: bold;
  418. }
  419. .mini
  420. {
  421. font-size: smaller;
  422. }
  423. .dt
  424. {
  425. margin-bottom: -.6em;
  426. }
  427. .indent
  428. {
  429. margin-left: 1.9em;
  430. margin-right: 1.9em;
  431. }
  432. .product
  433. {
  434. text-align: right;
  435. color: #333333;
  436. font-size: smaller;
  437. font-style: italic;
  438. }
  439. .buttonbarshade
  440. {
  441. position: relative;
  442. margin: 0;
  443. left: 0px;
  444. top: 2;
  445. width: 50%;
  446. height: 40px;
  447. }
  448. .buttonbartable
  449. {
  450. position: absolute;
  451. margin: 0;
  452. padding:0;
  453. border:0;
  454. left:0px;
  455. top: 2;
  456. width: 100%;
  457. height: 40px;
  458. }
  459. /* background color, font for header */
  460. table.buttonbartable td, table.buttonbarshade td
  461. {
  462. background: #ffffff; /*#5177B8; #80C615;*/
  463. border-left: 0px solid #80C615;
  464. margin: 0;
  465. padding: 0px 0px 0px 0px;
  466. font-family: Impact, sans-serif;
  467. font-size: 14pt;
  468. }
  469. table.buttonbartable td.button1
  470. {
  471. background: #5177B8; /*#80C615;*/;
  472. padding: 0;
  473. font-weight: bold;
  474. text-align: center;
  475. cursor: hand;
  476. }
  477. table.buttonbartable td.button2
  478. {
  479. background: #5177B8; /*#80C615;*/;
  480. font-weight: bold;
  481. text-align: center;
  482. }
  483. table.buttonbartable td.button3
  484. {
  485. background: #5177B8; /*#80C615;*/;
  486. font-weight: bold;
  487. text-align: center;
  488. }
  489. table.buttonbartable td.runninghead
  490. {
  491. padding-left: 0px;
  492. font-style: italic;
  493. text-align: left;
  494. }
  495. .version
  496. {
  497. text-align: left;
  498. color: #000000;
  499. margin-top: 3em;
  500. margin-left: -26px;
  501. font-size: smaller;
  502. font-style: italic;
  503. }
  504. .lang, .ilang
  505. {
  506. color: #0000ff;
  507. font: normal 7pt Arial, Helvetica, sans-serif;
  508. }
  509. div.langMenu
  510. {
  511. position: absolute;
  512. z-index: 1;
  513. width: 96pt;
  514. padding: 8pt;
  515. visibility: hidden;
  516. border: 1px solid #000000;
  517. background: #ffffd0;
  518. }
  519. div.langMenu ul
  520. {
  521. padding-left: 2em;
  522. margin-left: 0;
  523. }
  524. div.filtered
  525. {
  526. margin: 4pt 0 8pt -26px;
  527. padding: 4px 4px 8px 26px;
  528. width: 100%;
  529. border: 2px solid #aaaacc;
  530. background: #ffffff;
  531. }
  532. div.filtered2
  533. {
  534. margin: 4pt 0 8pt -26px;
  535. padding: 4px 4px 8px 26px;
  536. width: 100%;
  537. border: none;
  538. background: #ffffff;
  539. }
  540. div.filtered h1, div.filtered h2, div.filtered h3, div.filtered h4
  541. {
  542. margin-left: -22px;
  543. }
  544. div.filtered span.lang
  545. {
  546. position: relative;
  547. left: -22px;
  548. }
  549. div.reftip
  550. {
  551. position: absolute;
  552. z-index: 1;
  553. padding: 8pt;
  554. visibility: hidden;
  555. border: 1px solid #000000;
  556. background: #ffffd0;
  557. }
  558. a.synParam
  559. {
  560. color: #0000FF;
  561. /*color: #3F7800;*/
  562. /*color: #8DC54F;*/
  563. text-decoration: none;
  564. font-weight: normal;
  565. }
  566. a.synParam:hover
  567. {
  568. text-decoration: underline;
  569. font-weight: normal;
  570. }
  571. div.sapop
  572. {
  573. position: absolute;
  574. z-index: 1;
  575. left: 26px;
  576. width: 100%;
  577. padding: 10px 10px 10px 36px;
  578. visibility: hidden;
  579. border: 1px solid #000000;
  580. background: #ffffd0;
  581. }
  582. div.footer
  583. {
  584. width: 100%;
  585. border: none;
  586. background: #ffffff;
  587. margin-top: 18pt;
  588. padding-bottom: 12pt;
  589. color: #0000FF;
  590. /*color: #228B22; */
  591. text-align: center;
  592. font-size: 76%;
  593. }
  594. div.preliminary
  595. {
  596. margin-top: 8pt;
  597. padding-bottom: 12pt;
  598. color: #A0A0A0;
  599. }
  600. /* A procedure section. eg. 'To create a file', 'To add a value' */
  601. div.proc
  602. {
  603. margin-left: 0.5em;
  604. }
  605. /* The title of a 'procedure' section. */
  606. div.proc h3
  607. {
  608. font-family: Verdana, Arial, Helvetica, sans-serif;
  609. font-weight: bold;
  610. font-size: 115%;
  611. margin-top: 1em;
  612. margin-bottom: 0.4em;
  613. margin-left: -0.5em;
  614. color: #003399;
  615. }
  616. div.proc ul
  617. {
  618. margin-left: 1.5em;
  619. }
  620. div.proc ol
  621. {
  622. margin-left: 2.0em;
  623. }
  624. .note
  625. {
  626. margin-left: 14pt;
  627. margin-right: 12pt;
  628. }
  629. .indent1
  630. {
  631. margin-left: 12pt;
  632. }
  633. .indent2
  634. {
  635. margin-left: 24pt;
  636. }
  637. .indent3
  638. {
  639. margin-left: 36pt;
  640. }
  641. p.proch
  642. {
  643. padding-left: 16px;
  644. }
  645. p.proch img
  646. {
  647. position: relative;
  648. vertical-align: top;
  649. left: -18px;
  650. margin-right: -14px;
  651. margin-bottom: -18px;
  652. }
  653. div.clsPlatSpec
  654. {
  655. background-color:#FFF8DC;
  656. border-style:solid;
  657. border-width:1pt 0pt 0pt 1pt;
  658. border-color:#ffE4C4;
  659. margin-top:0.6em;
  660. width:100%;
  661. }
  662. /* Applies to the language labels in the Language Filter drop-down list. */
  663. .languageFilter
  664. {
  665. color: #0000FF;
  666. cursor:hand;
  667. text-decoration:underline;
  668. padding-bottom:4;
  669. }
  670. /* Dropdown areas */
  671. #languageSpan {
  672. position: absolute;
  673. visibility: hidden;
  674. border-style: solid;
  675. border-width: 1px;
  676. border-color: #C8CDDE;
  677. background: #d4dfff;
  678. padding: 4px;
  679. font-size: 70%;
  680. }
  681. #membersOptionsSpan {
  682. position: absolute;
  683. visibility: hidden;
  684. border-style: solid;
  685. border-width: 1px;
  686. border-color: #C8CDDE;
  687. background: #d4dfff;
  688. padding: 4px;
  689. font-size: 70%;
  690. }
  691. --></style>
  692. <xml>
  693. <MSHelp:TOCTitle Title="Waypoint Navigation" />
  694. <MSHelp:RLTitle Title="Waypoint Navigation" />
  695. <MSHelp:Keyword Index="A" Term="O:Microsoft.Xna.Waypoints" />
  696. <MSHelp:Keyword Index="A" Term="dd6736d0-e89c-4080-b794-a0e183f1766b" />
  697. <MSHelp:Keyword Index="K" Term="Waypoint Navigation" />
  698. <MSHelp:Attr Name="ProjType" Value="LocalProj" />
  699. <MSHelp:Attr Name="ProjType" Value="XNA_30" />
  700. <MSHelp:Attr Name="DocSet" Value="XNA" />
  701. <MSHelp:Attr Name="DocSet" Value="ExpressLibVS" />
  702. <MSHelp:Attr Name="DocSet" Value="C#" />
  703. <MSHelp:Attr Name="Locale" Value="en-us" />
  704. <MSHelp:Attr Name="CommunityContent" Value="1" />
  705. <MSHelp:Attr Name="AssetID" Value="dd6736d0-e89c-4080-b794-a0e183f1766b" />
  706. <MSHelp:Attr Name="TopicType" Value="kbOrient" />
  707. </xml>
  708. </head><body><div id="mainSection"><div id="mainBody">
  709. <h1>Waypoint Navigation</h1>
  710. This sample demonstrates basic navigation using waypoints.
  711. <a name="ID2EK"></a><h1 class="heading">Sample Overview</h1><div id="ID2EK" class="hxnx1">
  712. <p>
  713. When programming the AI for your game, you often want your actors to follow a path that you supply. For example, you may want units in your RTS to follow orders, or perhaps you want to make a mouse navigate a maze.
  714. </p>
  715. <p>
  716. This sample uses a tank to demonstrate two examples of this waypoint following behavior.
  717. In this sample, you can move the cursor around and add waypoints toward which the tank will move in the order that you add them.
  718. </p>
  719. <div class="alert"><table cellspacing="0" cellpadding="0"><tr><th>Note </th></tr><tr><td>
  720. This sample uses code and concepts from the Chase and Evade and Fuzzy Logic samples, and assumes that
  721. the reader is familiar with the code and concepts explained in those samples.
  722. </td></tr></table></div>
  723. <a name="ID2EU"></a>
  724. <a name="ID2EAB"></a><h2 class="subHeading">Sample Controls</h2><div id="ID2EAB" class="hxnx2">
  725. <p>This sample uses the following keyboard and gamepad controls.</p>
  726. <table>
  727. <tr>
  728. <th>Action</th>
  729. <th style="width: 295px">Keyboard Control</th>
  730. <th>Gamepad Control</th>
  731. <th>Windows Phone</th>
  732. </tr>
  733. <tr>
  734. <td>Move the cursor.</td>
  735. <td style="width: 295px">UP ARROW, DOWN ARROW, LEFT ARROW, RIGHT ARROW</td>
  736. <td>Left Thumbstick</td>
  737. <td>Drag the cursor</td>
  738. </tr>
  739. <tr>
  740. <td style="height: 26px">Place a waypoint.</td>
  741. <td style="width: 295px; height: 26px">A</td>
  742. <td style="height: 26px">
  743. <b>A</b>
  744. </td>
  745. <td style="height: 26px">
  746. Release the cursor on the screen</td>
  747. </tr>
  748. <tr>
  749. <td>Reset.</td>
  750. <td style="width: 295px">X</td>
  751. <td>
  752. <b>X</b>
  753. </td>
  754. <td>
  755. Touch the &quot;Clear&quot; button</td>
  756. </tr>
  757. <tr>
  758. <td>Change the waypoint following behavior.</td>
  759. <td style="width: 295px">B</td>
  760. <td>
  761. <b>B</b>
  762. </td>
  763. <td>
  764. Touch the behavior button</td>
  765. </tr>
  766. <tr>
  767. <td>Exit the game.</td>
  768. <td style="width: 295px">ESC or ALT+F4</td>
  769. <td>
  770. <b>BACK</b>
  771. </td>
  772. <td>
  773. <strong>BACK</strong></td>
  774. </tr>
  775. </table>
  776. </div>
  777. </div>
  778. <a name="ID2END"></a><h1 class="heading">How the Sample Works</h1><div id="ID2END" class="hxnx1">
  779. <p>
  780. The sample implements two types of behavior, <code>LinearBehavior</code> and <code>SteeringBehavior</code>, that determine how the tank moves from waypoint to waypoint.
  781. </p>
  782. <a name="ID2EYD"></a><h2 class="subHeading">LinearBehavior</h2><div id="ID2EYD" class="hxnx2">
  783. <p>
  784. <code>LinearBehavior</code> causes the tank to move directly and abruptly to its waypoint. It does this by setting the tank's <b>Tank.MoveSpeed</b> to its <b>Tank.MaxMoveSpeed</b> and setting its <b>Tank.Direction</b> to be exactly towards its current waypoint at all times. This makes the tank change direction instantly and always move in a straight line towards the waypoint.
  785. </p>
  786. </div>
  787. <a name="ID2EIE"></a><h2 class="subHeading">SteeringBehavior</h2><div id="ID2EIE" class="hxnx2">
  788. </div>
  789. <p>
  790. <code>SteeringBehavior</code> causes the tank to turn and to speed up or slow down smoothly as it moves toward the waypoint. It does this by using some geometry in <code>SteeringBehavior.FindMaxMoveSpeed</code> to determine its target velocity. Then, to turn smoothly, it uses <code>SteeringBehavior.TurnToFace</code> from the Chase and Evade sample.
  791. </p>
  792. <p>
  793. Given an angular velocity <i>w</i> and a linear velocity <i>v</i>, the turning radius <i>r</i> of the tank is:
  794. </p>
  795. <p>
  796. <i>r</i> = <i>v</i>/<i>w</i>
  797. </p>
  798. <p>
  799. Anything inside a circle tangent to the tank's position on either side of it is inside the tank's
  800. turning radius and cannot be reached at its current velocity.
  801. </p>
  802. <p>
  803. The solution is to estimate how fast the tank can move while still managing to reach its destination.
  804. We do this by finding the radius of the largest circle we can draw between the tank and its
  805. destination. Then, given this new radius, we use the following formula to determine a speed that guarantees
  806. that the tank can intercept its destination:
  807. </p>
  808. <p>
  809. <i>v</i> = <i>r</i> * <i>w</i>
  810. </p>
  811. </div>
  812. <a name="ID2EWF"></a><h1 class="heading">Extending the Sample</h1><div id="ID2EWF" class="hxnx1">
  813. <ul>
  814. <li>
  815. Add obstacles and a second behavior that causes the tank to move around the obstacles as it moves from waypoint to waypoint.
  816. </li>
  817. <li>
  818. Both tank behaviors have access to the list of waypoints, but both types of movement make use of the first remaining waypoint on the list. Create a new behavior that uses the built-in <code>Curve</code> class to fit all the waypoints onto a smooth curve that the tank can follow.
  819. </li>
  820. </ul>
  821. </div>
  822. </div><div class="footer" id="footer"><p>© 2010 Microsoft Corporation. All rights reserved.<br>Send feedback to <a href="mailto:[email protected]?subject=Documentation Feedback: Waypoint Navigation">[email protected]</a>.</p></div></div></body></html>