Creating a smooth path for character

Hey there all. I’m doing some initial tests for a 2D RPG. I know there are components out there to to what I’m trying to do but I want to try to do it myself.

So I’ve implented A* star algorithm which calculates the shortest path for a very basic test. Looks something like this: (the cross is the destination, the origin is where the cat is and the orange tiles are the shortest path the algorithm has pre-calculated)

So… all cool so far. But I’d like the character animation to be smooth, right now I have a path of 90 degree angles for when I animate the character towards the destination node. I’m thinking in creating quadratic bezier curves between the straight lines to make the animation look more natural. I want to end up with something like this: (This was done manually, not by script)

What do you think of this approach ?

Thanks for any suggestions.

Does it have to be an animation? I’m thinking more in terms of calculating a direction of travel every frame rather than calculating a curve.

I’m trying to imagine a system where the current direction of travel is based on the next two tiles, and the amount of influence of each direction depends on how far into the first on the character has traveled.

This way, as a tile is entered, the character should be moving mostly toward the next tile, but with a slight bias toward the next-next tile.

Something I’m unsure of is a way to track how “far into” a tile the character is. Maybe it could be based off of the distance to each tile, but they would have to be processed in some creative way. Maybe the distance to the nearest point on the next tile would work better?

Hopefully I’m making some sense.

3490893--277956--upload_2018-5-9_11-24-11.png

Example: Blue dot is current location. Red vector is direction to 1st-next tile, orange vector is direction to 2nd-next tile. Light blue vector is direction of character, found by a weighted angle interpolation between the red and orange, with red weighted higher since it’s the next tile.

Interesting approach Hyblademin, have you tried it ?

Nope. I did a couple checks to see if it made any sense, and it does when the current position is a boundary between two tiles, but I still haven’t thought of a way to define the necessary “progress” value used to weight the angles to the next two tiles.

My goal was to try suggesting a method that might be easier than generating an animation curve as a possible alternative, but I’m not sure I’ve done that.