Jump to content

building navmesh at runtime and using it for spawned aiplayers


Recommended Posts

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?


Link to comment
Share on other sites

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";


what comes next?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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";


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 filtering

https://github.com/GarageGames/Torque3D/blob/229132652e5006f64eb2fdf0e6acf8ee125bbba0/Engine/source/navigation/navMesh.cpp#L104 for regenerating the mesh around a given object.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...