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开发指南

第4章 意识体控制

本章主题:

  • 附加动画网格到智能体;
  • 为Lua动画状态机添加回调;
  • 让战士发射子弹;
  • 创建直接控制动画回放的智能体;
  • 创建处理动画回放的动画控制器;
  • 让智能体穿过障碍训练场。

目前为止,我们已经学会了基于转向力来移动智能体,并创建了一个处理动画网格的系统。现在我们将把这两个系统结合起来,构造具有可视形象和动画的可移动智能体。

再进一步,我们将用两种不同的方法来实现沙箱中的决策逻辑、意识、可视形象和身体。

目前为止,我们已经在沙箱和智能体的Lua脚本中硬编码了许多的功能。现在,我们将使用在src/demo_framework/script/Soldier.lua文件中提供的辅助函数来使用这些功能,而不是把这些代码到处拷贝。战士的Lua脚本中的函数专门调整过转向力和动画表现,用来构造一个向前走的战士。战士脚本中的动画状态机比我们之前构造的状态机要更为完整流畅。

现在先来浏览一下战士脚本提供的功能和使用方法。

Soldier.SoldierStates和Soldier.WeaponStates表为战士和他的武器的动画状态机提供了所有可用的动画的列表。

Soldier_AttachWeapon函数可以按照正确的位置和旋转偏移量将战士武器的网格关联到适当的骨骼上。

  function Soldier_AttachWeapon(soldier, weapon)

Soldier_CalculateSlowSteering函数将返回一个缓慢地转向一个正在环境中移动的智能体的转向向量。当智能体处于蹲伏状态时,我们将使用这个函数来控制转向。

  function Soldier_CalculateSlowSteering(agent, ...
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