`
varsoft
  • 浏览: 2436631 次
  • 性别: Icon_minigender_1
  • 来自: 上海
文章分类
社区版块
存档分类
最新评论

[游戏AI]实现掩蔽行为的策略

阅读更多
Strategies for Implementing Cover Behaviors
[游戏AI]实现掩蔽行为的策略
Share This | September 3rd, 2007 | Combat | Alex J. Champandard
原文地址:http://aigamedev.com/combat/cover-strategies
作者:Alex J. Champandard
译者:赖勇浩
Whilst catching up with recent discussions about game AI on the web, I stumbled on this thread about cover. Implementing good combat behaviors using cover isn’t always straightforward, but game developers often use the same tricks to solve this problem…
我偶尔发现在了这个讨论,终于让我赶上最近在网上关于游戏AI的讨论。利用掩体实现良好的战斗行为并非易事,但游戏开发者对于这个问题思路不多……
Screenshot: Finding and taking cover in Gears of War.
截图:《Gears of War(中译:战争机器)》中的角色懂得查找和利用掩体
Cover Behaviors
掩蔽行为
The actual behaviors are the most important part of the cover AI. If you get these right, the rest of the AI doesn’t have to be perfect as there’ll always be an appropriate fallback behavior when no cover is available nearby.
符合现实的行为是掩蔽AI 的最重要部分,如果你把这一点做好了,AI的并不需要做得非常完美,毕竟当周边没有可用的掩体的时候让角色撤退并无不妥。
Most actors require the following behaviors:
大多数角色需要这些行为:
1.Reacting to weapon fire by looking surprised for a short amount of time.
对开火作出反应,如在短时间内看起来很惊讶。
2.Assuming a intermediate position to search for cover, e.g. like dropping down on one knee.
假定一个中间位置来搜寻掩体,如单膝脆地
3.Playing a short animation while looking for cover, and signaling the threat to team mates.
在查找掩体的时候播放一个小动画,为队友打信号。
4.Moving swiftly but carefully into the most appropriate position,
快速而小心地移动到最恰当的位置。
5.Or alternatively, lying down on the spot for protection.
另一个可选的方式是就地卧倒。
Once you have the combat behaviors work correctly without using context sensitive cover, you can start thinking about scanning the environment for places to hide.
当你的战斗行为不再对掩蔽的环境敏感,可以正常工作,你就可以开始思考关于扫描环境来查找可以隐藏的地方的事了。
Manually Placing Cover Points
手动地标识掩蔽点
The simplest solution to allow actors to find cover locations in the world is to manually place them while editing the level. It’s a simple workflow that requires very little technology, so it’s often the best compromise.
让角色能够打到掩体的简单解决方案就是在编辑关卡的时候手动地标识掩蔽点。这个简单的工作流程只需要很少的技术,因此它的往往是最好的折衷办法。
Advantages
优势
Manual placement is a great way to fine tune the behaviors by placing cover locations exactly where you want them. So if you have special geometry, or need to customize the cover location per-level to fit in with a story, then manually adding cover locations to the level ideal.
手工放置的一大好处是你能够通过改变掩蔽点的位置来调整行为。因此,如果你有特殊的几何结构,或者需要为不同的故事制定不同的掩蔽点,那么可以手动增加掩蔽点。
Disadvantages
劣势
The only down side of this approach is that it requires more work by the level designers. To remedy this, you should consider attaching cover points to the object geometry (pillars, boxes, etc.), rather than for each instance in the world. Then, only add cover locations to static geometry as a fallback.
这一方法唯一不好的地方是需要关卡设计师做更多的工作。为了弥补这个缺点,可以考虑给几何结构对象附上掩蔽点信息(如柱子、箱子等),而非对游戏世界中的每一个实例手动编辑。然后只在静态几何结构上增加掩蔽点作为后备。
Ideally, you should start with manual cover point placement, then design your software to support multiple sources for cover spots. This will allow you to automate part of the process where possible.
理想的情况是,应该先使用手动放置掩蔽点的方法,然后设计你的软件以支持多种掩蔽点来源,这就有可能实现部分的自动处理。
Terrain Analysis
地物分析
If you feel confident about extending your level geometry pipeline, then terrain analysis becomes an option too. The idea is to use the structure of the world itself to find cover locations automatically. This process typically involves two steps: generating candidates and filtering out the bad ones.
如果你有信心扩展你的关卡结构管道,那么地物分析就变得可用了。它的思想是使用游戏世界自身的结构来自动查找掩蔽点。这一过程通常涉及两个步骤:产生候选掩蔽点和剔除不好的。
1) Generate cover candidates from the geometry
1)生成候选掩蔽点
To achieve the first step of generating cover candidates, you can use any of the 3D data available for each level. This includes the collision mesh (low and high detail), the navigation mesh, or even a waypoint graph.
生成候选掩蔽点的第一步是你能够利用关卡中的任何3D数据。包括碰撞网格(包括高、低细节)、导航网格或者是路点图。
Typically, the navmesh provides the most useful information as it models the floor of the environment very closely. Each external edge of the navmesh can be assumed to be around an obstacle of some kind, so generating cover points at fixed intervals along those edges is a very good strategy. Concave navmesh corners also provide you with information about leaning from cover, which would be very hard to determine otherwise.
通常导航网络能够提供最有用的信息,因为它与环境地面模型关系最为密切。导航网格的每一个外边都可以认为是某种障碍物的边缘,所以沿固定间隔的外边来生成掩蔽点是一个很好的策略。导航网格的凹角能够提供关于从掩蔽点倾侧的信息,不然这是难以计算的。
Using the waypoint graph also works, but it doesn’t have as good a sense of the floor as the navmesh. The result is that the waypoints are rarely placed perfectly up against the cover locations. It’s also much harder to annotate the cover points as places where leaning is supported.
路点图也能够工作得很好,但比起导航网格还是差一点。因为路点很少是与掩蔽点“紧贴”的,它也难以标注掩蔽点对于倾侧的支持。
2) Filter out invalid or bad choices for cover.
2)剔除不可用的与不够好的选择
The algorithm for generating cover candidates is typically very overeager, so it’s necessary to filter most of them out. To do this, you need to compute if each provides sufficient cover from any area of fire. A zone around each cover point should be scanned using line of sight (LOS) checks, either limited by a maximum radius or using the potentially visible set (PVS) in the level. If a cover location is hidden from a minimum area (customizable), then it should be saved for use at runtime as it may be useful.
该算法生成的掩蔽点许多都不可用或者不够好,所以需要剔除它们中的大部分。为了完成这一步,你需要计算是否能够掩蔽角色以抵挡任何地方发射的子弹,每个掩蔽点的周围都应当使用最大半径的视矩或使用关卡的潜在可见集进行扫描。如果掩蔽点的位置隐藏在很小的区域当中,那么应当在运行时把它保存起来,因为它相当有用。
Cover Selection
掩蔽点选择
Pre-processing cover locations helps greatly, but since most game situations change dynamically, there’s always some checking necessary at runtime. Typically, the cover selection algorithm takes into account:
对掩蔽点的预处理好处巨大,但随着更多的游戏支持动态变化的场景,就需要在运行时进行检验了。通常而言,掩蔽点选择的算法考虑以下两点:
Position and orientation of the enemies to determine the source of fire.
敌人的位置与方向确定为开火点。
Accessibility of cover points, and is return fire possible.
掩蔽点的可及性,反击的可能性。
A good place to start for cover selection is to implement a scoring mechanism for neighboring locations. You can add different heuristics to rank the cover points as necessary, and the actor will always try to pick the best.
一个极佳的方法就是对周边的位置实现计分机制,必要时可以为掩蔽点增加不同的启发式排名,那么角色将始终挑选其中最好的。
What techniques do you use to find cover for your actors?
你用什么技术来让角色找到掩蔽点?
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics