Game Development Community

torque 3d v3.5 navpath useage?

by gdyxml2000 · in Torque 3D Professional · 02/10/2014 (7:46 am) · 21 replies

in the editor I create a NavMesh and a NavPath,and set parameters,so what about the next in the script calling?

in the "Empty Terrain.mis" :
...
new NavMesh(Nav) {
fileName = "NavFile1";
cellSize = "0.2";
cellHeight = "0.2";
tileSize = "10";
actorHeight = "2";
actorClimb = "3";
actorRadius = "0.5";
walkableSlope = "40";
alwaysRender = "0";
borderSize = "1";
detailSampleDist = "6";
detailSampleError = "1";
maxEdgeLen = "1086324736";
simplificationError = "1.3";
minRegionArea = "8";
mergeRegionArea = "20";
maxPolysPerTile = "128";
position = "180 -80 250";
rotation = "1 0 0 0";
scale = "50 50 50";
canSave = "1";
canSaveDynamicFields = "1";
};
new NavPath(xx1) {
from = "0 0 1";
mesh = "Nav";
isLooping = "0";
alwaysRender = "0";
xray = "0";
position = "0 0 0";
rotation = "1 0 0 0";
scale = "1 1 1";
canSave = "1";
canSaveDynamicFields = "1";
};
...


in the script(game/scripts/gui/playGui.cs):

// Add the function onRightMouseDown as follows:

function PlayGui::onRightMouseDown(%this, %pos, %start, %ray)
{
commandToServer('movePlayer', %pos, %start, %ray);
}


in the script(scripts/server/commands.cs):

function serverCmdmovePlayer(%client, %pos, %start, %ray)
{

%ai = %client.player;

%ray = VectorScale(%ray, 1000);
%end = VectorAdd(%start, %ray);


%searchMasks = $TypeMasks::TerrainObjectType | $TypeMasks::StaticTSObjectType |
$TypeMasks::InteriorObjectType | $TypeMasks::ShapeBaseObjectType |
$TypeMasks::StaticObjectType;


%scanTarg = ContainerRayCast( %start, %end, %searchMasks);

// If the terrain object was found in the scan
if( %scanTarg )
{
%pos = getWords(%scanTarg, 1, 3);
// Get the normal of the location we clicked on
%norm = getWords(%scanTarg, 4, 6);

// Set the destination for the AI player to
// make him move
%ai.setMoveDestination( %pos );
}
}



so , how to use the navPath data to direct the AI player to wherever you right-click on the terrain


Page«First 1 2 Next»
#21
06/03/2014 (8:14 pm)
Thanks for that report, Jesse! The Generator class has been renamed since 3.5.1, which I hadn't picked up on. I'll do another patch when 3.6 hits, but I'll update the documentation ASAP and make a note in the official thread.
Page«First 1 2 Next»