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

Method setPathDestination

Engine/source/T3D/aiPlayer.cpp:771–827  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

aiPlayer.cppFile · 0.80
on3DMouseDownMethod · 0.80

Calls 3

successMethod · 0.80
registerObjectMethod · 0.45
deleteObjectMethod · 0.45

Tested by

no test coverage detected