Stingray Forum (Read Only)
Welcome to Autodesk’s Stingray Forums. Share your knowledge, ask questions, and explore popular Stingray topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Navigation in LUA - follwing guide with no success

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
oyalco
708 Views, 3 Replies

Navigation in LUA - follwing guide with no success

I am attempting to implement navigation in LUA in the character template project following this guide: http://help.autodesk.com/view/Stingray/ENU/?guid=__stingray_help_creating_gameplay_ai_and_pathfindin...  I am having some trouble, though it's possible I am making some elementary errors. I only started looking at Stingray and LUA a couple of days ago so am a complete newbie.

 

I need access to NavWorld and NavBotConfiguration so I am doing the following at the top of player.lua:

 

local NavWorld = require 'core/gwnav/lua/runtime/navworld'
local NavBotConfiguration = require 'core/gwnav/lua/runtime/navbotconfiguration'

 

player.lua might not be the correct file to do this in, but it is giving me access to init(), update() and so on. If it's not the correct file, please let me know what I should do. I am then trying to set up the NavWorld and a bot.

 

function Player:init()

    -- OMITTED CODE!
	
    print("creating navworld")
    self.navworld = NavWorld(world, level)
    -- Both in the above line show in Debugger View as tables.
    -- Both have different IDs* in Debugger View.
    --(* if that is the correct terminology....)
    
    print("creating navdata")
    --local nav_data = self.navworld:add_navdata("content/levels/character")
    -- The above line is from the example but leaves nav_data as nil as add_navdata()
    -- returns nothing - it has no return statement in its code when stepped into.
    self.navworld:add_navdata("content/levels/character")
    local nav_data = self.navworld.navdata
    -- nav_data show in Debugger View as 'unknown light user data'. 
    
    print("creating navbot")
    local configuration = NavBotConfiguration
    -- Both in the above line show in Debugger View as tables.
    -- Both have different IDs in Debugger View.
    configuration.height = 1.8

    local unit = World.spawn_unit(SimpleProject.world, "content/models/props/projectile", Vector3(0,0,10))
    -- I'm creating a projectile as I just want a unit to test with at this stage.
    -- I have tested the line above and can see it has spawned in the world.

    local navbot = self.navworld:init_bot_from_unit(unit, configuration)
    -- On the above I get the error further below in this post.
end

The console output is:

 

 

Test Engine / Lua: core/gwnav/lua/runtime/navworld.lua:113: bad argument #1 to 'get_data' (userdata expected, got table)

Current index offset is: 1


Lua Callstack
----------------------------------------

    [1] [C]: in function get_data
    [2] core/gwnav/lua/runtime/navworld.lua:113: in function init_bot_from_unit
    [3] script/lua/player.lua:128: in function init
    [4] core/appkit/lua/class.lua:16: in function Player
    [5] script/lua/player.lua:282: in function spawn_player
    [6] script/lua/project.lua:38: in function on_level_load_pre_flow
    [7] core/appkit/lua/simple_project.lua:127: in function load_level
    [8] core/appkit/lua/simple_project.lua:181: in function init
    [9] [string "..."]:11: in main chunk 

Lua Locals
----------------------------------------

    [2] self = table: 00000000162DA890, unit = [Unit 'content/models/props/projectile'], configuration_unit = table: 00000000162DB088
    [3] self = table: 00000000162DA100, nav_data = [unknown light userdata], configuration = table: 00000000162DB088, unit = [Unit 'content/models/props/projectile']
    [4] self = table: 00000000162D9180, object = table: 00000000162DA100
    [5] level = [Level], view_position = Vector3(0, -8, 3), view_rotation = Vector4(0, 0, 0, 1)
    [6] level_name = content/levels/character, view_position = Vector3(0, -8, 3), view_rotation = Vector4(0, 0, 0, 1), Player = table: 00000000162D9180
    [7] resource_name = __level_editor_test, level_name = content/levels/character, world = [World], config = table: 0000000015A81A20, extension_project = table: 0000000016289B58
    [8] config = table: 0000000015A81A20, world = [World], world_wrapper = table: 0000000016285158, camera_unit = [Unit 'core/appkit/units/camera/camera'], standalone_init_level_name = content/levels/main_menu, level_resource_name = __level_editor_test
    [9] orig_update = [function]

I have tried to discover how I can create an instance of NavBotConfiguration as userdata not a table but have had no success, and nor am I sure that's the correct approach anyway. Can anyone show me where I've gone wrong? I've spent most of the day on this and I have no idea what to do now, so any help would be greatly appreciated!

 

Tags (1)
3 REPLIES 3
Message 2 of 4
james.park
in reply to: oyalco

Hi,

 

You are trying to pass a table as a unit.  That won't work.

 

If you just want to create a bot using a configuration you've instantiated yourself, you can do the following:

 

local navbot = NavBot(self.navworld, unit, configuration)

 

Let me know if that works.

 

Cheers.

Message 3 of 4
dan.matlack
in reply to: james.park

Thanks James! oyalco, please let us know if that solves your issue. 🙂
______________________________________
Dan Matlack
Senior Content Manager || Games Solutions
Autodesk, Inc.
Message 4 of 4
oyalco
in reply to: james.park

James, thanks very much. That solved it!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report