MoveEntity.htm 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <html>
  2. <head>
  3. <title>Blitz3D Docs</title>
  4. <link rel=stylesheet href=../css/commands.css type=text/css>
  5. </head>
  6. <body>
  7. <h1>MoveEntity entity,x#,y#,z#</h1>
  8. <h1>Parameters</h1>
  9. <table>
  10. <tr>
  11. <td>
  12. entity - name of entity to be moved <br />
  13. x# - x amount that entity will be moved by <br />
  14. y# - y amount that entity will be moved by <br />
  15. z# - z amount that entity will be moved by
  16. </td>
  17. </tr>
  18. </table>
  19. <h1>Description</h1>
  20. <table>
  21. <tr>
  22. <td>
  23. Moves an entity relative to its current position and orientation. <br />
  24. <br />
  25. What this means is that an entity will move in whatever direction it is facing. So for example if you have an game character is upright when first loaded into Blitz3D and it remains upright (i.e. turns left or right only), then moving it by a z amount will always see it move forward or backward, moving it by a y amount will always see it move up or down, and moving it by an x amount will always see it strafe.
  26. <br>
  27. <br>
  28. See also: <a class=small href=TranslateEntity.htm>TranslateEntity</a>, <a class=small href=PositionEntity.htm>PositionEntity</a>, <a class=small href=PositionMesh.htm>PositionMesh</a>.
  29. </td>
  30. </tr>
  31. </table>
  32. <h1><a href=../3d_examples/MoveEntity.bb>Example</a></h1>
  33. <table>
  34. <tr>
  35. <td>
  36. ; MoveEntity Example <br />
  37. ; ------------------ <br />
  38. <br />
  39. Graphics3D 640,480 <br />
  40. SetBuffer BackBuffer() <br />
  41. <br />
  42. camera=CreateCamera() <br />
  43. light=CreateLight() <br />
  44. <br />
  45. cone=CreateCone( 32 ) <br />
  46. <br />
  47. ; Move cone in front of camera, so we can see it to begin with <br />
  48. MoveEntity cone,0,0,10 <br />
  49. <br />
  50. While Not KeyDown( 1 ) <br />
  51. <br />
  52. ; Reset movement values - otherwise, the cone will not stop! <br />
  53. x#=0 <br />
  54. y#=0 <br />
  55. z#=0 <br />
  56. <br />
  57. ; Change rotation values depending on the key pressed <br />
  58. If KeyDown( 203 )=True Then x#=-0.1 <br />
  59. If KeyDown( 205 )=True Then x#=0.1 <br />
  60. If KeyDown( 208 )=True Then y#=-0.1 <br />
  61. If KeyDown( 200 )=True Then y#=0.1 <br />
  62. If KeyDown( 44 )=True Then z#=-0.1 <br />
  63. If KeyDown( 30 )=True Then z#=0.1 <br />
  64. <br />
  65. ; Move cone using movement values <br />
  66. MoveEntity cone,x#,y#,z# <br />
  67. <br />
  68. ; If spacebar pressed then rotate cone by random amount <br />
  69. If KeyHit( 57 )=True Then RotateEntity cone,Rnd( 0,360 ),Rnd( 0,360 ),Rnd( 0,360 ) <br />
  70. <br />
  71. RenderWorld <br />
  72. <br />
  73. Text 0,0,"Use cursor/A/Z keys to move cone, spacebar to rotate cone by random amount" <br />
  74. Text 0,20,"X Movement: "+x# <br />
  75. Text 0,40,"Y Movement: "+y# <br />
  76. Text 0,60,"Z Movement: "+z# <br />
  77. <br />
  78. Flip <br />
  79. <br />
  80. Wend <br />
  81. <br />
  82. End
  83. </td>
  84. </tr>
  85. </table>
  86. <br>
  87. <a target=_top href=../index.htm>Index</a><br>
  88. <br>
  89. Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=MoveEntity&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
  90. </html>