path finding question - refrasing

Started by
13 comments, last by cyberia_2ooo 21 years, 2 months ago
well... as i guessed the discription of my problem was too vauge (damn, i hope this is the right spelling of the word) anyway, i''ll try to refrase... i have square grid (just to be sure u understand me, i mean not a hexagonal one and not an isometric one... a simple grid) which represend a map.... no i have a path on this map... a path is a list of adjacent coordinets on the grid. not i have a certein unit that needs to follow the path... i want the unit, at any time to face the point it is going... how do i do it???? p.s. if you have any ideas for me about group movment that can be good for implimatation for strategy games, please tell me... but that''s not really important right now... it''s for later
Advertisement
by the way, by my understanfing boids will do the work i want, but is it a good solution for RTS game?
Hey... take a look at the A-star algorithm and apply it to your game

Anyway... if you want to make a simplier version do like this:

From the point of your character expand paths like a circle. First expand to each direction and check if its possible to walk on that tile, if not tha kill that path and don''t use it anymore.
When you checked each direction, you expand one more tile and check if that one is walkable, if not... then once again kill that path. Do this until you reach the position you want your object to walk to. And of course choose tha fastest way to get there. This is not a VERY good way of solving your problem, but it works... and it works better the less times you expand... since this could eat your memory if you do this too many times.

Well and as for the problem where your object face... its quite simple. Just check what the next tile of the chosen path is in.

Oh well, just want to say that I actually never tried this method but to mee it seems that it should work OK.

GL, hope this helps~
i have a path....
i now want the unit to walk down that path...
i don''t know hot to make it face the direction it is going...
Do you want it to face towards the final destination at all points along the path? You will need to do some trigonometry (sin, cos). Do you want it to face the direction it is about to move towards? You need to change the image depending upon the direction it is moving, i.e. map x,y velocity values to an orientation of the sprite; read up on vectors.
"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
checking the next tile is not a good solution...
because:
a. if lets the path is no a perfect diagnol and not a straghit line... it would be funny looking...
b. i have more thatn 8 direction pics... i want to use them all to make a more realistic rotating
So trigonometry it is then. You will also need to work out the "turning points" on the board (which isn''t going to be trivial) and orient yourself, using the angles you get back from the trig, towards each turning point. Using splines is another possibility.

I''d take a look at a few path-finding articles, there are some in the articles section of this site.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
have no problem with trig, my problem is finding the turning points, i have no idea how to that...
It just occured to me that this problem is similar in some ways to drawing a line between two points. Try googling for "Bresenham Line Algorithm" or "fast line algorithm" and see if anything inspires you.

______________________________

And the Phoenix shall rise from the ashes...

--Thunder_Hawk -- ¦þ
______________________________
______________________________________________________________________________________The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ"So. Any n00bs need some pointers? I have a std::vector<n00b*> right here..." - ZahlmanMySite | Forum FAQ | File Formats______________________________________________________________________________________
How many directions have you got?
______________________________________________________________________________________The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ"So. Any n00bs need some pointers? I have a std::vector<n00b*> right here..." - ZahlmanMySite | Forum FAQ | File Formats______________________________________________________________________________________

This topic is closed to new replies.

Advertisement