Hi,
As the final part of my pathfinding script i have a part which lets you make an event follow the route that the algorithm predicted.
Now what my script does is check what direction the next tile in the route is and then calls $game_map.events[eventNumberHere].move_right or whatever direction the next tile happens to be in.
The problem is all the move commands seem to get done nearly all at the same time so the event doesn't follow the path properly, it skips pretty much straight to the destination. What i am trying to do is make it so if for example it calls move_right it will then wait for the event to actually fully walk to that square before it calls the next move command.
The code i am using to try and do this at the moment is this, but it doesn't seem to work:
As you can see that code is copied from the end of the update method of the Game_Character class, from the part that calls the normal movement. I.e. if you set the event movement to random, i figured that would work. But it didn't!
Any help would be much appreciated!
Edit:
I've managed to find a solution thanks, rather than reinventing the wheel so to speak i searched through the RPGXP Data stuctures and sent the event the route as a move event command.
As the final part of my pathfinding script i have a part which lets you make an event follow the route that the algorithm predicted.
Now what my script does is check what direction the next tile in the route is and then calls $game_map.events[eventNumberHere].move_right or whatever direction the next tile happens to be in.
The problem is all the move commands seem to get done nearly all at the same time so the event doesn't follow the path properly, it skips pretty much straight to the destination. What i am trying to do is make it so if for example it calls move_right it will then wait for the event to actually fully walk to that square before it calls the next move command.
The code i am using to try and do this at the moment is this, but it doesn't seem to work:
Code:
# Updates to game_character class
# If pathfinding is active calls the correct move
# commands...
class Game_Character
alias original_update update
def update
# Call old update stuff
original_update
# Check if ready to move again... if so
# Check if pathfinding active, if so then call the
# pathfinding walking method
if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
if $game_map.pathfinding
$pathfinding.walk
end
end
end
end
As you can see that code is copied from the end of the update method of the Game_Character class, from the part that calls the normal movement. I.e. if you set the event movement to random, i figured that would work. But it didn't!
Any help would be much appreciated!
Edit:
I've managed to find a solution thanks, rather than reinventing the wheel so to speak i searched through the RPGXP Data stuctures and sent the event the route as a move event command.