Not even sure if my approach is correct but I’m trying to get a pawn to stop along a designated path once that path exceed an X cost (X being a set float variable).
So far I can get the cost of a path but can’t figure out how to stop along the path when the path cost exceeds X.
In the pawn check the path cost in “Event Tick”. If it exceeds, “stop” the pawn ;).
This is the simplest solution, i assume you have the path cost in the corresponding pawn and the pawn should handle its own stopping. If not, or if you dont know how to actually stop your pawn, provide more details.
Ok so as working with AIControllers is beyond my knowledge I can only give you a way that could work for you. It is flawed as it will cause problems if the calculated navigation path is not in a straight line, or when there are other objects in its way. You could use this and instead of calling SimpleMoveToLocation if the path cost exceeds call itself (OrderReceived) with the new calculated EndLocation until you get a result that fits (or have to abort). But I am pretty sure there is a much better performing solution to this.
Let the answer open for a few weeks and hope for someone more experienced than me.
Ok I’ll try and give a detailed explanation of what I’ve done so far. I’m probably going about a few of these things backwards so feel free to ping me on better ways to approach some of these issues if you see them.
For starters after I’ve used left click to select a pawn my character controller is then casting the location of the mouse using the following graph:
I use this to vector to control the Target Mesh (which is just a plane with a material to display the current end location) and when I write click I cast the location of the pawn and the location of the Target Mesh to the AI Controller so it can execute movement:
After the AI Controller receives the two vectors I can than calculate the cost of the whole path, print the value, than execute a simple move node to get the pawn to move to the location:
After all that you can see in the image below the result. You have the selected “ship” with a circle around it than another circle that is the current end location and finally a print screen of the current cost for the path:
Finally, the issue I’m having is I can’t figure out how to get the actor to stop where the path cost exceeds X amount. With the last image you can see that the path cost is over 1000, so how do I get the pawn to stop at 1000 if I choose that to be it’s maximum range of movement?
Cheers for the feedback man. I was experimenting with something like that and discovered another problem where using the “Get Path Cost” node sometimes returns a zero result even though the character is moving to a new location. Same thing happens with “Get Path Length” and can’t seem to figure out a solid solution to it, but will try implementing this when I can figure out that issue.
good luck, and be sure to post your own answer when you archieved it for future people wo will search for this