Is there a common way to implement a character following path that is issued and replaced in real time?
For example: the character follows a path issued, and while it's on that path, if a new path is issued, the character abandons the existing one and follows the new path from where it is currently located.
Here's a more detailed explanation:
I am trying to make a real-time action game, like Diablo, but in 2D and tile-based. The player can issue new destinations on the map and the in-game character should walk towards that destination in real time.
I got the path finding part all worked out, but I am having issues with getting the character to smoothly abandon an existing path, and follow a new path (when a new destination is issued).
The character sometimes flickers when a new path is issued while it's following an existing path. If the character sprite is not at the centre of a tile, it will "teleport" to the centre of the tile it's on and follow the path from there on smoothly.
I tried to get around this problem by first checking if the player is on at the centre of a tile, and if not, I amend a node in the front of the new path to get the player to move to that tile. But this still doesn't get me the desired effect, because if the same destination is issued over and over, the character will just keep walking to the same tile instead of walking towards that destination.