well, i have it working with an incremental pathfinding way, but it has a problem. once it reaches the destination it keeps on moving in the direction it came from until the distance from the point he was going first is greater than the distance to the point he is supposed to be going to. what i need is a way to completely ignore the point ( and all others ) that are nót the ones he is going to, in other words only regard the waypoint actor that has the correct hitag as the only actor he could find.
tate navigate // navigate to the waypoint.
findnearactor WAYPOINT 409600 TEMP
getactor[TEMP].hitag MHITAG // TEMP is in this case the waypoint actor.
ifvarvare MHITAG COUNT // make sure the waypoint he is going to is the next sequential one, so he doesnt backtrack.
// IE only find nearactor with a hightag the count currently has, one at a time.
ifvarn TEMP -1 // the actor should only care about the waypoint if both statements return true.
{
getactor[TEMP].x MX
getactor[TEMP].y MY
getactor[THISACTOR].x x
getactor[THISACTOR].y y
subvarvar MX x
subvarvar MY y
getangle ANGVAR MX MY
setactor[THISACTOR].ang ANGVAR
}
// here starts my own changes to make the system do what i need.
// if the actor is within the accepted distance from the waypoint, make him aim for the next one by adding one to the count.
findnearactor WAYPOINT 512 TEMP2
getactor[TEMP].hitag MHITAG
ifvarn TEMP2 -1
ifvarvare MHITAG COUNT // add 1 to count only if the current waypoint has the same value as the one where the player was moving towards,
// used to prevent a retrigger causing the count to rise 1 every tick the actor is within the set distance
{
addvar COUNT 1
spawn EXPLOSION2 // just to check if he reaches the correct point, and does not re-trigger the count. set off fireworks one you reach your goal.
break // force restart of the subroutine
}
ends
i tried putting a ifvarvarn MHITAG COUNT { break } after the actual getting the angle code but that didnt seem to work, if i place a waypoint between the actor, and it has not the correct hitag the actor will then ignore the one that does have the correct hitag, this makes figure 8 forms impossible, wich is something i could live with, but surely there is a way around it.
i was thinking allong the lines of running a search through the spriteid's until it finds the correct one before proceeding.
but my actor does not follow a simple path i layed out start to finish, so thats a win.