MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / setPathDestination

Method setPathDestination

Engine/source/T3D/aiPlayer.cpp:786–842  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

784}
785
786bool AIPlayer::setPathDestination(const Point3F &pos)
787{
788 // Pathfinding only happens on the server.
789 if(!isServerObject())
790 return false;
791
792 if(!getNavMesh())
793 updateNavMesh();
794 // If we can't find a mesh, just move regularly.
795 if(!getNavMesh())
796 {
797 //setMoveDestination(pos);
798 throwCallback("onPathFailed");
799 return false;
800 }
801
802 // Create a new path.
803 NavPath *path = new NavPath();
804
805 path->mMesh = getNavMesh();
806 path->mFrom = getPosition();
807 path->mTo = pos;
808 path->mFromSet = path->mToSet = true;
809 path->mAlwaysRender = true;
810 path->mLinkTypes = mLinkTypes;
811 path->mXray = true;
812 // Paths plan automatically upon being registered.
813 if(!path->registerObject())
814 {
815 delete path;
816 return false;
817 }
818
819 if(path->success())
820 {
821 // Clear any current path we might have.
822 clearPath();
823 clearCover();
824 clearFollow();
825 // Store new path.
826 mPathData.path = path;
827 mPathData.owned = true;
828 // Skip node 0, which we are currently standing on.
829 moveToNode(1);
830 throwCallback("onPathSuccess");
831 return true;
832 }
833 else
834 {
835 // Just move normally if we can't path.
836 //setMoveDestination(pos, true);
837 //return;
838 throwCallback("onPathFailed");
839 path->deleteObject();
840 return false;
841 }
842}
843

Callers 2

aiPlayer.cppFile · 0.80
on3DMouseDownMethod · 0.80

Calls 4

getPositionFunction · 0.85
successMethod · 0.80
registerObjectMethod · 0.45
deleteObjectMethod · 0.45

Tested by

no test coverage detected