This tutorial will teach you the basics of the Blender Game Engine, and how to create a platform game, which is a game where you overcome in-game obstacles by controlling the character's motions. (e.g. Super Mario)
::本教程将教你使用Blender游戏引擎的基础知识,以及如何创建平台游戏,这是一个通过控制角色动作来克服游戏中的障碍的游戏. (例如超级马里奥)

Set Up
::设置

How it should look so far.

To start, switch to the frontal view  NUM1  and move the starting cube to -3.0 along the Z azis, or three spaces down. If your default settings do not have you starting with a cube, create one now. (Don't forget to switch to the Blender Game engine. You can do this by going to the button on the top center of the screen that says Blender Render and switch it to Blender Game.) Next, hit  SPACE  →  Add → Mesh → Monkey  to create Suzanne the Monkey. Any mesh will do, but it's the easiest of the basic meshes to intuitively determine local direction from. Next, go to the logic window (with Suzanne still selected) and toggle on "Actor" and then "Dynamic". Hit  PKEY  to test. Suzanne should fall, then stop upon hitting the cube. Press  ESC  to exit.
::开始时,切换到前视图NUM1并将开始方块移动到-3.0沿着Z azis,或向下三个空格.如果您的默认设置没有开始方块,现在就创建一个. (不要忘记切换到混合游戏引擎.您可以通过进入屏幕上方的按到屏幕上方的中间,该按表示混合游戏染并切换到混合游戏进行.接下来,按空格 → 添加 → 网格 → 子来创建子苏珊娜.任何网格都可用,但这是最简单的基本网格,以直观地确定本地方向.接下来,进入逻辑窗口 (仍然选择了苏珊娜),然后切换到"演员"然后按"动态".PYKEY测试苏珊娜.应该

Controls
::控制方式

Now we will add the controls. First, forward:
::现在我们将添加控制.

In Blender 2.59 these controls are available in the 'Logic Editor' window.
::在Blender 2.59中,这些控制可以在"逻辑编辑器"窗口中使用.

  1. Create a Keyboard Sensor, AND Controller, and Motion Actuator. Connect them by dragging lines between the dots next to their names. (In 2.59 the controller is created automatically, if the other two are connected)
    ::创建一个键盘传感器,AND控制器和运动执行器.通过在它们的名字旁边的点之间拖动线来连接它们. (在2.59中,如果其他两个连接,控制器会自动创建)
  2. Select the empty box next to the word "Key" on the Keyboard Sensor and hit the up arrow key on your keyboard.
    ::选择键盘传感器上"键"字旁的空框, 然后按键盘上的上箭头键.
  3. Set the dLoc on the Motion Actuator to 0.10 Z and toggle Local Transformation (may appear as simply an L next to the dLoc row).
    ::设置动作执行器的dLoc为0.10Z,并切换本地转换 (可能仅仅显示为dLoc行旁边的L).

Next, backward. Repeat the process used for forward, but set the dLoc to -0.10 Z and the key to the down arrow. You can repeat this for left and right if you so choose to have a linear control scheme. We will not be using such a scheme for this tutorial, but you should still be able to follow along just fine. Instead, the character will rotate left and right and move in the new forward and backward.
::接下来,向后.重复前进的过程,但将dLoc设置为-0.10 Z,并将键设置为向下箭头.如果您选择使用线性控制方案,您可以重复左和右.我们不会在本教程中使用这样的方案,但您仍然可以很好地跟进.相反,字符将旋转左和右,并在新的前进和后退中移动.

(Note: Using an X or Y value for Dloc may be more effective as using Z value seems to just make her jump not move in any sort of direction which defeats the purpose of the final step of the tutorial)
::通过使用Z值似乎只会让她跳跃, 而不是在任何方向移动, 这就打败了教程最后一步的目的.

To rotate right:
::转向右边:

  1. As before, create a Keyboard Sensor, AND Controller, and Motion Actuator, then connect them.
    ::像之前一样,创建一个键盘传感器,控制器,和动作执行器,然后连接它们.
  2. Set the key to the right arrow and set the dRot to -0.10 Y.
    ::设置键到右箭头,并设置dRot到-0.10Y.

Repeat for left, with the left arrow and 0.10 Y.
::用左箭头和0.10Y重复左边的操作.

Finally, the ubiquitous, and some say defining, Platformer move: the jump. Repeat the previous processes, with the space key as the trigger and the linV of the motion effect as 7.50 Z (not local). This doesn't actually move the character in a certain direction, but sets its velocity. If you've done programming for games before, this will probably be familiar to you. Each frame, the engine adds the velocity of the object to its current position. The gravity portion of the engine subtracts from the upward velocity each time. When it reaches a negative, it's adding a negative number to its altitude, ergo subtracting from it, ergo causing it to fall. This is why using linV to move the character does not cause it to immediately relocate to the target position.
::最后,无处不在,有些人说定义,平台运动:跳跃.重复前面的过程,用空格键作为触发器和运动效应的linV为7.50Z (不是本地).这实际上并没有将角色移动到某个方向,而是设置其速度.如果你以前做过游戏编程,这可能会很熟悉.每一,引擎将对象的速度添加到当前位置.引擎的重力部分每次从上升速度中减去.当它达到负值时,它将增加负数到它的高度,因此从它中减去,从而导致它跌落.这就是为什么使用linV来移动角色不会立即导致它重新定位.

Last modified: Monday, 17 March 2025, 1:59 PM