游戏邦在:
杂志专栏:
gamerboom.com订阅到鲜果订阅到抓虾google reader订阅到有道订阅到QQ邮箱订阅到帮看

分享跑酷游戏的角色控制设计经验

发布时间:2015-04-10 17:37:29 Tags:,,,,

作者:Evan Todd

你可能想制作一款超现实主义基于立体像素的第一人称的跑酷游戏。你正努力制定一个产品计划。哪个环节最耗时?图像?声音?还是关卡设计?我打赌一定是角色控制。我还打赌这会耗费4年半的时间,为什么?

*跑酷游戏的玩家移动极为重要,需要大量时间才能摸准正确的感觉。

*每款游戏都有自己的特点,你绝对找不到解释如何针对你自己的游戏展开设计的文章或攻略。你只能自己摸着石头过河。

也就是说,每款游戏都有一些值得借鉴的智慧和经验。在此以我自己的亲身经历为例。

制作角色

你是一名程序员,但在处理GIMP的时候也能如鱼得水,你认为自己也算是合格的美工。你可以绘制玩家角色了。

parkour ninja(from gamasutra)

parkour ninja(from gamasutra)

这个角色的问题就出在于它过于兴奋和有趣。你可以让它更无趣和普通一点吗?使用MakeHuman试试怎样?它可以用模版生成人类角色。

makehuman(from gamasutra)

makehuman(from gamasutra)

这样更好一点了,但还是有一个问题:这是一款第一人称游戏,所以当玩家往下看时,就会看见自己的鼻子。

并且“胸肌”也会显得有点高,会让玩家对自己的性别产生困惑。

look down(from gamasutra)

look down(from gamasutra)

你可能就会干脆替换成女性角色。

针对鼻子的问题,你无法移除整个头,因为无头阴影看起来有点不协调。那么削掉整张脸如何?

face(from gamaustra)

face(from gamaustra)

(最后你还是得重新修改模版,雇佣一名美术人员,为第一人称视角和阴影渲染器使用无头模版,但这一点都不好玩。)

令角色移动

你可以使用一个带有简单角色控制器的强大物理引擎,如下图:

cylinder 1(from gamasutra)

cylinder 1(from gamasutra)

这个角色是一个漂浮在地面上的圆柱体,由一个射线支撑。这样,圆柱体就可以清除一个小障碍,当射线穿过它时,整个仪器就会跳到表面。

由于游戏世界是由立体像素组成,你很快就会遇到这个问题:

cylinder 2(from gamasutra)

cylinder 2(from gamasutra)

有许多玩家在首次测试中会卡在这里。你可能不会花时间去寻找一个完美的解决方案,而是像这样倒饬一番:

cylinder 3(from gamasutra)

cylinder 3(from gamasutra)

尽管如此,玩家还是被卡住了。你就会诉诸碰撞处理器让角色远离那些可能产生问题的东西。你还会增添一个垂直位置以便摄像机在角色穿越不平坦的立体元素时正常发挥功能:

before-after(from gamasutra)

before-after(from gamasutra)

为了更准确地模拟现实,游戏此时不会有空气控制。你最初制定这个决策时,你多少会忘记游戏是一个虚构的立方体世界。

倾听玩家反馈之后,你可能就改变了主意。在现实世界中,跑酷游戏有许多关系到准确跳跃的控制维度。

令游戏有趣

因为跑酷游戏与冲力相关,你要让角色花数秒时间达到其最大速度。这并没错,只是低加速会让角色速度的微调更困难。

你要如何使用不同的加速度则要取决于当前的速度。最终的速度曲线如下:

time curve(from gamasutra)

time curve(from gamasutra)

这解决了一半的问题,但玩家还是可能用鼠标将摄像镜头转90度,将速度重置为0。

你经过多次受挫的试验,最终采用了点积这一解决方案。它实际上是基于量级衡量两个矢量之间角度的工具。

你用点积找出角色的边对边动量。如果它们处于自己动量方向的垂角,点积就会很大。你可以借此增加速度。长话短说,也就是转向不再阻碍冲力。

让游戏更流畅

还有其他情况可能让玩家丧失冲力,比如撞到墙壁。你试图用低摩擦物质来缓解这一问题,但面对墙壁调整方向总会降低你的速度:

你可以参考Mike Bithell针对这一问题发布的博文。你使用3条射线以及一些向量积计算出一个可以沿着墙体滑行的速度。

之后你又会发现其他头疼的问题。你的立体元素引擎有时候会构建出像这样的立体元素:

seam(from gamasutra)

seam(from gamasutra)

由于浮点错误,两个相隔立方体之间会产生缝隙。当角色贴着墙体奔跑并试图向上跳跃时,就会撞到缝隙并立即停下来。

这个问题很容易解决,只要将圆柱体改成胶囊体就行了。没错,我就是花了4年时间才想到这个。

宽容对待玩家

最初,玩家不懂游戏的移动机制。他们认为自己无法从A点走到B点,除非你在背后指给他们看,并解释如何操作。你可能会认为这是因为你还没有推出新手教程所致。

最后,新手教程也到位了。人人都理解了游戏的移动机制,也知道如何操作。但现在又有一个新问题了:他们陷入了行动跟不上计划的困扰。

这里的罪魁祸首就是教程中的一次跳跃误导。它试图告诉玩家如何抓住平台,因为轻轻一跃并不足以成功跨越平台之间的鸿沟。

jump(from gamasutra)

jump(from gamasutra)

在你告诉玩家“长摁按钮”之前,玩家可能会失败两三回,而这却有助于他们摸准跳跃时机,尽管这一方式有点粗暴。有趣的是,他们完成这次跳跃后,之后就可以无需长摁按钮地完成其他跳跃。你可能会由此认为玩家很蠢。

部分原因仍要归咎于教程:你让玩家充满信心地跳跃,采取他们之前从不知道的行动。他们并不知道角色会做什么,执行操作需要多长时间。所以你又增加了另一个更初级的教程,让玩家在一个安全的环境中尝试抓住平台边缘。

但还是存在如何抓准时机的问题。这里有双重解决方法:

*让玩家离开平台边缘时立即起跳半秒。

*让他们摁住按钮而不是在揪准时机点触按钮。

success(from gamasutra)

success(from gamasutra)

这样可以减少人们在游戏中的受挫感,并令游戏更具趣味性。

美化游戏

在开发过程中,你会遇到一些动画方面的问题。只要使用足够漂亮的程序生成动画,也许人们并不会注意到你拙劣的绘画技巧和纹理问题。

*令摄像机视角附于角色头盖骨的位置,但要使用一个独立的根骨来控制摄像旋转。这可以消除动画之间进行混合时的异常旋转现象。

*使用双重曲线而非直线来混合动画。

*不要使用线性矩阵插值,要使用四元插值。

*在快速转向时,要使用点积令角色和摄像机倾斜。

*通过过滤器进行角色变形,以便获得上下视角时角色倾斜头部的良好效果。

*在适当时候要植入玩家的双脚并播放一点步履蹒跚的动画效果。

总结

parkour from gamasutra)

parkour from gamasutra)

开发者要在角色控制器上投入大量时间才能制作出独一无二的效果。如果你也和我一样,还要做好多次犯错的心理准备。(本文由游戏邦编译,转载请注明来源,或咨询微信zhengjintiao)

The Poor Man’s Character Controller

by Evan Todd

Let’s say that, like so many of us, you want to make a surreal voxel-based first-person parkour game. You’re trying to figure out a production schedule. What will take the longest? Graphics? Sound? Level design? I bet it will be the character controller. And I bet it will take 4½ years. Why?

In running/jumping games, player movement is paramount. It takes forever to nail the right feeling.

Each game is a unique snowflake. You will not find an article explaining how to design the controls for your specific game. You’re flying blind.

That said, each game offers a few transferrable bits of wisdom. Here’s my story.

Make a character

You’re a programmer, but one time you were able to suppress the gag reflex while using GIMP, so you’re pretty much an artist too. You can draw a player character.

That’s certainly… a drawing. So the player is an anthropomorphized cylinder? Well, we’ve seen worse.

If this character has any flaw, it’s that he’s too exciting and interesting. Can you make him a little more boring and generic? What if you use MakeHuman? It literally generates human characters from a template.

Much better. But there’s just one problem: this is a first-person game, so when players look down, they can see their own nose:

Also, the “pectoral musculature” slider is a tad high, and players are getting confused about their gender.

You end up switching to a female character. Because why not?

Now for the nose problem. You can’t remove the entire head, because a headless shadow might be somewhat disconcerting. What if you just remove the face?

Perfect.

(Eventually you revamp the model, hire an animator, and use separate models, one sans head, for the first-person view and shadow renderer. But none of that is entertaining.)

Make it move

You’re using a great physics engine (seriously, it’s quite good) that comes with a simple character controller. It looks like this:

The character is a cylinder floating above the ground, supported by a single raycast. This way, the cylinder can clear a small obstacle, and once the raycast hits it, the whole apparatus jumps on top.

Since the game world is made of voxels, you quickly run into this problem:

Tons of players get stuck this way in your first alpha release. Rather than spend time on an elegant solution, you brute-force it:

Despite this, people still get stuck. You resort to a collision handler that actually pushes the character away from anything that could cause problems. You also interpolate the vertical position to smooth out the camera when traversing uneven voxels:

Make it unrealistic

In an attempt to model reality accurately, the game has no air control at this point. When you originally made this decision, you somehow forgot that the game is about an imaginary cube world.

Thankfully, after listening to player feedback, you have a change of heart. In the real world, traceurs have many control dimensions (namely, their muscles) that enable precise jumps. Video games have exactly one button. Air control is only fair.

Make it fun

Since parkour is about momentum, you want the character to take several seconds to reach max speed. Which is fine, except that low acceleration makes small adjustments difficult. The first step takes forever, and the character feels like a semi truck.

Your solution uses different accelerations depending on the current speed. The final speed curve looks like this:

This solves half the problem, but players can still use the mouse to quickly whip the camera around 90+ degrees, which resets their speed back to zero.

You experiment with a few hacks, but eventually settle on a solution using the dot product. It’s basically a measure of the angle between two vectors multiplied by their magnitude. (Here’s a quick interactive demo.)

You use a dot product to find out how much side-to-side momentum the character has. If they’re facing perpendicular to the direction of their momentum, the dot product will be large. You use that to increase the acceleration. Long story short, turning no longer burns momentum.

Make it slippery

There are other ways to lose momentum, like running into a brick wall. You try to mitigate this with low friction physics materials, but angling yourself into a wall will always slow you down:

You are inspired by a blog post by Mike Bithell on this topic. You use three raycasts and some cross product magic to figure out a velocity that will slide along the wall.

Later on, you discover another annoyance. Your wonderful voxel engine sometimes helpfully constructs voxels like this:

There’s a seam between the two adjacent blocks due to floating point error. When the character moves flush with the wall and tries to jump upward, it hits the seam and immediately stops.

The solution is brain-dead simple: change the cylinder to a capsule. Yes, it really does take you 4 years to figure this out.

Make it forgiving

At first, players just don’t understand the movement mechanics. They think they can’t get from point A to point B, until you tap them on the shoulder and explain they have to do XYZ. You suspect this is because your tutorial is actually a placebo at this point.

Eventually, the tutorial gets pretty good. Everyone understands the movement capabilities, and they can figure out which moves to use. But now they have a new problem: they fail in the twitchy execution and timing details of their plans.

The worst culprit is a single infamous jump in the tutorial. It tries to teach players how to grab ledges because it’s too long to cross with a normal jump.

Players fail two or three times before you tell them to “button-mash”, which helps them nail the timing through sheer brute-force. Interestingly, as soon as they make this one jump, they have no trouble completing future jumps without button-mashing. For a while, you arrogantly conclude that people are just stupid.

Part of the problem is still the tutorial: you ask players to make a leap of faith and perform a move they’ve never seen before. They have no idea what the character will do or how long it will take. So you add another, earlier tutorial that lets players try out the ledge grab in a safe space.

But the frustration of perfect timing remains. The solution is two-fold:

Let players jump for a split second after they walk off an edge.

Let them hold buttons instead of tapping at the right moment.

To the surprise of no one but you, this makes the game a lot less frustrating and a lot more fun.

Make it look good

Over the course of development, you stumble on a few animation tricks. With enough nifty procedural animation, maybe people won’t notice your shoddy weight painting and texture work!

Attach the camera position to the character’s head bone, but use a separate root bone to control camera rotation. This eliminates weird rotations when blending between animations.

Speaking of which, use a quadratic curve to blend between animations rather than straight linear.

Also, don’t use linear matrix interpolation. Instead use quaternion interpolation.

Remember the dot product from earlier, for calculating side-to-side momentum? Use that to make the character and camera lean when turning at speed.

Run the character bone transforms through filters for nice effects like tilting the character’s head when looking up and down.

Plant the character’s feet and play a little foot-shuffling animation when turning in place.

(For a much more eloquent and in-depth look at procedural animation, check out David Rosen’s GDC talk.)

Conclusion

Budget an extraordinary amount of time for your character controller. Make it special and unique. And if you’re me, prepare to be wrong most of the time.(source:gamasutra


上一篇:

下一篇: