First of all, the paths for pawns are done with ScriptPoints, not PathPoints. PathPoints are a completely different thing. Maybe that's why you haven't used them succesfully?
Anyway, I guess the hardest part of this is to aquire the closest ScriptPoint of the right type. There is a command called:
bool NearestPoint(float MinDistance, float MaxDistance );
Search for the nearest visible ScriptPoint within the range MinDistance - MaxDistance and if one is found, make it the current ScriptPoint (success is indicated by the return value).
But it might return a ScriptPoint belonging to a patrol path when you want to get a cover point. All ScriptPoints are alike to this command. However, there are some little tricks that can be done. You could name all your patrol points something like
patrol1,
patrol2,
patrol3 etc. The attack path would be similar:
attack1,
attack2 etc. And cover points:
cover1,
cover2 etc.
Then, for example if you have 20 patrol points in the level and you want to check which one is closest, you can use this piece of script:
Code: Select all
nearestpatrolpoint_distance = 100000;
nearestpatrolpoint = 0;
for i = 1 to 20 // cycle through all 20 points
{
if(GetDistanceTo("patrol"#i) < nearestpatrolpoint_distance) // if this point is nearer than any of the previous ones
{
nearestpatrolpoint_distance = GetDistanceTo("patrol"#i);
nearestpatrolpoint = i;
}
}
NewPoint("patrol"#nearestpatrolpoint); //set the new scriptpoint
nearestpatrolpoint_distance and
nearestpatrolpoint are variables that you have to define in the start of the script.
You can replace "patrol" with "attack" or "cover" to get the nearest point of the other types.
You can then use the command:
NextPoint();
Get the NextPoint entry from the current ScriptPoint and make it the current ScriptPoint. If no entry exists then the current ScriptPoint will be invalid and references to it will be ignored.
To make the pawn follow the current path.
I hope this gets you started. I know, it may be hard to understand, but I'm in a sort of a hurry so I can't write a more detailed tutorial.
Pain is only psychological.