이 문서에서는 Gameware Navigation을 Lua 게임 코드로 통합하는 방법에 대해 설명합니다. 탐색 표준을 추가하고 봇을 생성하는 방법에 대해서 살펴볼 것입니다.
사용자의 런타임에서 Navigation 통합을 시작하기 위해 Autodesk는 Lua 스크립트 세트를 제공하고 있습니다. 프로젝트에 사용할 수 있도록 이러한 스크립트는 core/gwnav/lua/runtime에 있습니다.
통합을 위한 기본 구성요소는 Navigation 표준입니다(navworld.lua 필요).
이 오브젝트에서 다음 작업을 수행할 수 있습니다.
수준 초기화에서 다음과 같이 NavWorld 오브젝트를 생성합니다.
function MyGame:init() self.navworld = NavWorld(world, level) end
포함:
탐색 표준은 각 프레임에서 업데이트되어야 합니다. 또한 시각적 디버깅을 위해 기본 게임 카메라를 보낼 수 있어 게임에 연결하면 Navigation Lab의 카메라와 게임 카메라가 일치할 수 있습니다.
function MyGame:update(dt) self.navworld:update(dt) self.navworld:visual_debug_camera(self.maincamera) end
표준에 NavData를 추가하는 방법:
function MyGame:init() local nav_data = self.navworld:add_navdata("levels/empty") end
표준에서 NavData를 제거하는 방법:
self.navworld:remove_navdata(nav_data)
게임 호출 시 탐색 메시를 렌더링하려면 다음과 같이 입력합니다.
self.navworld:debug_draw(gui, line_object)
초기화된 Gui 및 LineObject를 이 함수로 전달해야 합니다. 또한 표준에 일부 NavData를 추가했어야 합니다.
function MyGame:shutdown() self.navworld:shutdown() end
NavWorld에 봇을 추가하는 방법:
local configuration = NavBotConfiguration() -- You can change any parameters of the configuration: configuration.height = 1.8 local navbot = self.navworld:init_bot_from_unit(unit, configuration)
NavWorld에서 봇을 제거하는 방법:
navbot:shutdown()
상자 장애물을 생성하는 방법:
local box_obstacle = NavBoxObstacle(navworld, unit) box_obstacle:add_to_world() box_obstacle:remove_from_world() -- obstacles is not destroyed, just no longer present in world
navworld는 이 장애물을 놓아 두려는 NavWorld입니다. unit은 상자 장애물을 연관시키려는 Unit입니다. 이는 다음 스크립트 데이터에 따라 구성됩니다.
원통 장애물을 생성하는 방법:
local cylinder_obstacle = NavCylinderObstacle(navworld, unit) cylinder_obstacle:add_to_world() cylinder_obstacle:remove_from_world() -- obstacles is not destroyed, just no longer present in world
navworld는 이 장애물을 놓아 두려는 NavWorld입니다. unit은 원통 장애물을 연관시키려는 Unit입니다. 이는 다음 스크립트 데이터에 따라 구성됩니다.
장애물을 삭제하는 방법:
box_obstacle:shutdown() cylinder_obstacle:shutdown()