Introduction
::引言

This tutorial is intended as an improvement on its prequel,  Platformer: Creation and Controls , and will require files created through that tutorial. It is also recommended that you read  An aMAZEing game engine tutorial  as well before beginning this tutorial. It will require a familiarity with the Blender UI, simple commands (such as AKEY to select) and basic modeling skills. This tutorial will introduce the following features and improvements:
::本教程旨在改进其前作"Platformer:创建和控制",并且需要通过该教程创建的文件.还建议您在开始本教程之前阅读"一个惊人的游戏引擎教程".它需要熟悉Blender的用户界面,简单的命令 (如AKEY) 和基本的建模技能.本教程将介绍以下功能和改进:

  1. only letting the character jump while touching the ground
    ::只有让角色在触及地面时跳跃
  2. stop the character from bouncing greatly upon hitting an object
    ::阻止角色在撞到物体时大大跳跃
  3. where to adjust material friction
    ::在哪里调整材料摩擦

This tutorial was written for version 2.45.
::这教程是为2.45版本编写的.

Creating Your Hit Test Object
::创建自己的测试对象

Copy the cube with  SHIFT-D . Go into edit mode, select the bottom four vertices of the cube and delete them. Go back to object mode. Go to the editing panel in the buttons window. In the Link and Materials section, change the ME: value to "Square" and the OB: value to "FloorHit". In the Mesh section, there will be three buttons with the word "center" in them; Center, Center New, and Center Cursor. Press Center New. This will change the origin of the "Square" mesh to the center of all of its vertices, instead of the center of the cube you made it from. Scale it to 0.99% of the original and move it up 0.01 along Z. Now go to the shading panel and make sure you're in the Material buttons subpanel. Find Links and Pipeline, and make sure "ME is selected. Click the X next to the material selection (under the words "Link to Object"). Then select "OB" and press "Add New" and name this material "FloorHit" (again, no quotes). Make it green colored, so you can easily find it while editing, but turn on "Shadeless" and "No Mist" in the Material section and "OnlyCast" in the Links and Pipeline - Render Pipeline section and turn off "Radio", "Traceable", and "Shad(ow)buffer" in the Render Pipeline and "Shadow" in the Shaders section. This will make it completely invisible at runtime and take up little resources.
::用SHIFT-D复制立方体.进入编辑模式,选择立方体的底部四个顶点并删除它们.回到对象模式.进入按窗口的编辑面板.在链接和材料部分,将ME:值更改为"方块"和OB:值更改为"FloorHit".在网格部分,将有三个按,其中包含"中心"字;中心,中心新,和中心光标.按中新.这将将"方块"网格的起源更改为其所有顶点的中心,而不是您从中建立的立方体的中心.将其缩小到原始的0.99%并将其移动到0.01 Z.现在进入遮蔽面板,并确保您在材料子面板中.找到管道链接和材料,并确保"ME"

(question: it wont make it invisible it just flashes rapidly)
:伤心问题:它不会让它看不见,它只是快速闪)

Making the sensor require floor contact
::让传感器需要与地板接触

Now select Suzanne and go to the logic panel. Add a touch sensor called "jumpcol" (for 'jump collision') and connect it to the same AND controller as the jump keyboard sensor. Set the f to 10 and the MA: to FloorHit. This will make it so your character can only jump while it's touching something with the FloorHit material. By that same token you can link this to  all  of your movement-related AND controllers so that the player can't adjust it's movements in mid-air. This is a nice physics touch but for most platformer games, where mid-air dexterity is almost essential, it doesn't work. You also have to use Force and not dLoc, otherwise your character won't be able to move at all while jumping, useless your character only needs to hit things with his/her head, and not jump over gaps. Note that this still does not keep the character from jumping while touching the hit test object at the sides, so they could still jump if they were touching the side of the collision surface, but at least they can't jump in mid-air or while touching the bottom of the ground. I have yet to find a solution to this problem not involving Python.
::现在选择Suzanne,然后进入逻辑面板. 添加一个称为"jumpcol" (用于"跳碰撞") 的触摸传感器,并将其连接到与跳键盘传感器相同的AND控制器. 设置f为10和MA:为FloorHit. 这将使你的角色只能在触摸FloorHit材料的东西时跳跃. 同样,你可以将此链接到所有与运动有关的AND控制器,以便玩家不能在空中调整它的运动. 这是一个很好的物理触摸,但对于大多数平台游戏,在空中灵巧几乎是必不可少的,它不起作用. 你还必须使用Force而不是dLoc,否则你的角色在跳跃时根本无法移动,你的角色只需要用头击中东西,而不是跳过. 注意,这个

Excessive Bouncing
::过度跳跃

Another problem with the original model, as you might have noticed, is that when you run into one of the ground cubes you bounce back a great deal. To fix this, turn to the materials panel with one of your green hit test squares selected. Under the color selectors there should be three buttons that say "RGB", "HSV", and "DYN". Select DYN, and turn the restitution most or all the way up. As you can see, you can also find the friction property from here, if you want your ground to be more or less frictional (like mud or ice).
::原型的另一个问题,正如你可能已经注意到的,当你碰到地面立方体时,你会反弹很大.为了解决这个问题,转向材料面板,选择一个绿色的测试方块.在颜色选择器下应该有三个按,上面写着"RGB"",HSV"和"DYN".选择DYN,然后将恢复最大或全部向上.正如你所看到的,如果你想让你的地面或多或少地摩擦 (如泥或冰),你也可以从这里找到摩擦属性.

Final Notes
::结论性说明

Always copy your floors, their respective hit test objects, and other generic objects with  ALT-D  and not  SHIFT-D . This keeps you from duplicating things that remain the same for every one, like the material and mesh, which quickly drain resources if not recycled. Since there's not much further you can take the Platformer without learning Python, I suggest you start looking up information on the Blender API. Some essential information is to be found in the  procedural object creation  tutorial. A Blend file of the tutorial's finished product is coming soon.
::总是用ALT-D而不是SHIFT-D复制你的地板,它们的相应的击中测试对象,以及其他通用对象. 这使得你不会重复对每个对象保持相同的东西,比如材料和网格,如果不回收,它会很快耗尽资源. 因为没有更多的东西可以在不学习Python的情况下使用Platformer,我建议你开始查找Blender API上的信息. 一些基本信息可以在程序对象创建教程中找到. 教程的最终产品的Blend文件将很快发布.

Note : A (possibly) simpler method for jump limitation can be found on the discussion page for this tutorial.
::注意: (可能) 更简单的跳跃限制方法可以在本教程的讨论页面上找到.


最后修改: 2025年03月17日 星期一 14:13