Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How to make a sprite to follow the shortest path generated by AI Path Finder?  (Read 2354 times)

0 Members and 1 Guest are viewing this topic.

magneonx

  • Full Member
  • ***
  • Posts: 141
    • MSN Messenger - magnumneon04@hotmail.com
    • View Profile
Hello! The title says it all,

But to give some few tips for this is that:

first, I have made a Tileset, which is a container of class Tile where I made a 2d vector of shared_ptrs for a Tile. Tile contains info on cost that constitutes the formula of F = G(n) + H(n).

second, the shortest path are stored for in a vector named closedList which is a vector of Tiles*.
So this is where I am going to take the shortest path.

It seems that, the web is full of tutorials on AI Path Finding, I have implemented mine as well, but does give constraints on actually moving the sprite to from point A to point B? I just followed the exact algorithm so I could make sure this is right, and it was right, or should I just reprogram my AI code to accomodate to such requirement of actually moving the sprite from point a to point b?

Thanks!

mike38

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Michael's Software Site
Why can't you just say to the sprite:
' Move to the next tile, if I am there, then move to the next tile'?

if (sprite_position == next_tile_centre)
{
    next_tile_centre = best_path.at( next_tile_id )
}

sprite_position = sprite_position + (next_tile_centre / player_speed)?
 
?

Or am I not getting your question?

magneonx

  • Full Member
  • ***
  • Posts: 141
    • MSN Messenger - magnumneon04@hotmail.com
    • View Profile
Anyway thanks for the reply, yeah we have the same idea, what I am doing right now is to traverse the path generated by the Path Finder itself, it was contained in a vector so what I do is I make a point at the center of the tile and I compute its direction to get there. So far my computations are working but I haven't tried the actual movement yet. I was busy this past few days thanks for the idea at least I know where I gonna set off from here.

 

anything