slapin Posted September 10, 2017 Share Posted September 10, 2017 Hi all!I was looking very hard for how to instantiate navmesh at run time and save it into save game for later use and could not find anything.Is there some example?Also I tried to use pre-made navmesh with spawned aiplayer but could not find any example on how to do that and what I miss.I probably don't know enough to search properly so could you please help and provide some info (best for post 3.7 or latest version).Any links?Thanks! Quote Link to comment Share on other sites More sharing options...
Duion Posted September 10, 2017 Share Posted September 10, 2017 You could trigger to regenerate the navmesh while the game is running, you can regenerate small parts like one cell to save performance. Quote Link to comment Share on other sites More sharing options...
slapin Posted September 10, 2017 Author Share Posted September 10, 2017 I'd kill for an example though.My map is randomly generated at start, so I need to have navmesh generated at start,then small portions can be generated.But I wonder how to use the result mesh.i.e. if I use from script $navmesh = new NavMesh() { position = "0 0 0"; scale = "512 512 10"; }; $navmesh.build(); what comes next? Quote Link to comment Share on other sites More sharing options...
Duion Posted September 10, 2017 Share Posted September 10, 2017 Try out the functions in the world editor on the navmesh, there is an option to select single tiles and regenerate them.But in your case it is probably enough to generate the navmesh once as a whole at start, it will add quite some loading time though, since navmesh generation takes a while.You need to try it in editor first manually to find good settings. Quote Link to comment Share on other sites More sharing options...
Azaezel Posted September 12, 2017 Share Posted September 12, 2017 Old create on the fly code is old, but should by and large still be accurate function addNav() { %newMesh = new NavMesh(theNavMesh) { saveIntermediates = "0"; buildThreaded = "1"; build = "0"; fileName = "levels/temp/nav.nm"; //<--------------------- file save loc borderSize = "1"; cellSize = "0.3"; cellHeight = "0.25"; actorHeight = "2"; actorClimb = "0.25"; actorRadius = "0.3"; walkableSlope = "45"; detailSampleDist = "6"; detailSampleError = "1"; maxEdgeLen = "12"; simplificationError = "1.3"; minRegionArea = "8"; mergeRegionArea = "20"; tileSize = "32"; renderMode = "Navmesh"; renderInput = "0"; renderConnections = "0"; position = "0 0 3.5"; rotation = "1 0 0 0"; scale = "30 30 10"; //<--------------------- dimensions canSave = "1"; canSaveDynamicFields = "1"; alwaysRender = "0"; cornerAngle = "30"; createCoverPoints = "0"; renderContours = "0"; renderGeometry = "0"; renderNavmesh = "1"; renderSegments = "1"; }; MissionGroup.add(%newMesh); } https://github.com/GarageGames/Torque3D/blob/229132652e5006f64eb2fdf0e6acf8ee125bbba0/Engine/source/navigation/navMesh.cpp#L669 for generating the mesh results.https://github.com/GarageGames/Torque3D/pull/1573 for per-object filteringhttps://github.com/GarageGames/Torque3D/blob/229132652e5006f64eb2fdf0e6acf8ee125bbba0/Engine/source/navigation/navMesh.cpp#L104 for regenerating the mesh around a given object. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.