Skip to Content
Lua游戏AI开发指南
book

Lua游戏AI开发指南

by Posts & Telecom Press, David Young
May 2024
Beginner to intermediate
327 pages
4h 38m
Chinese
Packt Publishing
Content preview from Lua游戏AI开发指南

第3章 角色动画

本章主题:

  • 加载动画网格到沙箱;
  • 附加网格到动画骨骼;
  • 沙箱中战士和武器的动画;
  • 混合多个动画;
  • 创建Lua动画状态机;
  • 创建战士和武器的动画状态机。

当沙箱功能基本就位并能显示一个基本的智能体之后,我们可以着手为它添加动画,使它看起来更像一个真人。虽然目前我们可以给智能体附加一个基础的人物网格,但是如果没有动画它仍然缺乏生气。

动画系统对于AI的表现和功能都非常重要。沙箱AI只能在有动画时才能执行动作,虽然给人的直观感觉并非如此。如果一个动画需要播放5分钟且中途不能打断,则我们的AI在执行动作时就需要考虑到这种情况,否则AI会在这5分钟内失去响应。

首先简单介绍一下沙箱如何表达和使用的动画。

到目前为止,我们已经知道如何在沙箱中创建网格的表现。现在我们继续处理另一种称为骨骼的资源。Ogre(沙箱的底层渲染器)把骨骼和动画一起存储在单一的.skeleton文件中。沙箱中每个动画网格引用的动画都放在media/animations文件夹下,比如我们的战士的动画位置在media/ animations/futuristic\_soldier/futuristic\_soldier.skeleton。

将一个动画网格加载到沙箱的方法和加载普通网格没有区别。简单地调用Core.CreateMesh函数就可以创建一个动画网格了。

Sandbox.lua:   function Sandbox_Initialize(sandbox)     local soldier = Core.CreateMesh(       sandbox,       "models/futuristic_soldier/" ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Python迁移学习

Python迁移学习

Posts & Telecom Press, Dipanjan Sarkar, Raghav Bali, Tamoghna Ghosh
R深度学习权威指南

R深度学习权威指南

Posts & Telecom Press, Joshua F. Wiley
精通模块化JavaScript

精通模块化JavaScript

Nicolás Bevacqua

Publisher Resources

ISBN: 9781836205555